1.The Following Links for know about Files in c++ CplusPlusTutorial for Files CplusCplus Tutorial for Files |
2.Useful tutorial about create MFC Dialog MfCDialog |
3.Any error occurred during compilation in MFC dialog based application vc++6.0 following link will be useful for handle that. VC++ Error Message |
4.When I Run Cpp program it show error c1010 precompiled directive- Solution:
- Include header statement in your cpp file
- Using namespace std;
|
5.When error occur on reading a file, like getline is undeclared identifier - Solution:
- Put #include header file in your cpp program
- Refer this link if any clarification
|
6.Call Exe from MFC Exe ShellExecuteEx - Solution:
- If you want to execute a exe file form the mfc dialog application in vc+6.0 we can use ShellExecute or System or ShellExecuteEx Funtion Better Use the ShellExecuteEx funtion beacuse this function We can run any (.exe)file using ShellExecuteEx command it will handle the time taken to complete the loading process , onces it completed executing return 0 otherwise wait for the process until complete.
|
7.How to call Firefox.exe through command line parameter - The Following link will be useful for how to call every command through commandlineargument
- Command Line Parameters
|
8.To Changing backcolor of dialog follow this link - Change Background color of dialog in mfc
|
9.How to display a string in window or button etc at runtime using variable - Solution
- In Vc++6.0 all string are in lpcstr format so you can declare variable as normal string and caste to c.str() and pass it to function.
- Example:
- String sample;
- SetwindowText(sample.c_str());
|
10.How do we remove file from a folder ? - Solution:
- Use the following code
- If( remove( "path”)!= 0 )
- perror( "Error deleting file" );
- else
- puts( "File successfully deleted" );
- return 0;
|
11.How do we pass variablename for giving path to open dynamic file at run time - Convert the string variable name to c.str(). and pass it the ifstream function
- variablename=”path”;
- if(remove(variablename.c_str())!=0)
|
12.How do we set font for statictext or button caption ,radiobuttons etc., - SetFont
- CFont m_Font; put this in header file of dialog
- Add the following code to the initdialog
- LOGFONT lf;
- memset(&lf, 0, sizeof(LOGFONT)); // zero out structure
- lf.lfHeight = 12; // request a 12-pixel-height font
- strcpy(lf.lfFaceName, "Arial"); // request a face name "Arial"
- VERIFY(m_Font.CreateFontIndirect(&lf)); // create the font
- Call through member function
- m_btton.SetFont(&m_font);
- Follow this link is useful
|
13.How do display file contents or button using loop in dialog window continuously - We can call Doevents Function it repaint the window for each iteration .
- Example
- void DoEvents() // for display at a time
- {
- MSG msg;
- if(::PeekMessage(&msg,NULL,0,0,PM_REMOVE))
- {
- ::TranslateMessage(&msg);
- ::DispatchMessage(&msg);
- }
- }
|
14.ADD PAGE UPAND PAGE DOWN in dialog window - How to Trigger function when pagdown and page up key is pressed
- Follow this link
|
15.How do we change the title of the dialog Windows ? If we create the mfc dialog application in some sample name, we want to rewrite the title name of the dialog window Write this code on InitDialog Example: SetWindowText(“This is new title”); |
16.How to display color text in button or label ,static text ? |
- Using OnCtlColor() function we can display color text
- Example:
- When this function called by program?
-
- If we have create control at runtime ,it will call after creating control
-
- (i)Decalaring function OnCtlColor() as a protected in dialogheader file
-
- HBRUSH CclassnameDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
-
- (ii)Define function with in DlgCpp file.
-
- HBRUSH CRefreshcontDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
- {
- HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
- if (pWnd->GetDlgCtrlID()==controlid )//if(nCtlColor==CTLCOLOR_BTN)
- {
- pDC->SetTextColor(RGB(255, 0, 0));//redcolor
- pDC->SetBkColor(RGB(255, 255, 255));//background white color
- }
- return hbr;
- }
|
17.How to set a pageup and down event in dialog mfc? - Add PreTranslateMessage function to your code by right click on dialogbox ,click classwizard and click add the function and click ok. In coding window write the following message.
- Example:
- if(pMsg->message==WM_KEYDOWN)
- {
- OnKeyDown(pMsg->wParam, LOWORD(pMsg->lParam), HIWORD(pMsg->lParam));
-
- After that the same procedure followed by adding the PreTranslateMessage function to dialog window ,like that this function (WM_KEYDOWN) is added to your code window, OnKeyDownEvent catch the pageup or down when user press the key
- if ( nChar == VK_PRIOR )
- {
- OnVScroll(SB_PAGEUP, 0, NULL);
- }
- else if ( nChar == VK_NEXT )
- {
- OnVScroll(SB_PAGEDOWN, 0, NULL);
- }
- When we press page up or down , this keydown will call vscroll function for move the cursor positon to pageup or down.
|
18.How do we capture the button position in dialog window in mfc? - We use GetDlgItem function for getting the id of the control and use following code.
- Example:
- POINT pts;
- CWnd *pwnd = GetDlgItem(IDC_BUTTON1);
- pwnd->GetWindowRect(&rc);
- pts.x = rc.left;
- pts.y = rc.top;
- ScreenToClient(&pts);
|
19.How we will open multiple tabs in the firefox using command line arguments? Firefox.exe www.google.com www.codeguru.com www.qualitypointtech.com |
No comments:
Post a Comment