I do not know programming dialog based programming very well, but after a lot of effort I got to write the following code:
//Program to take the Name of person as input in a TEXT box and display //it in a MessageBox
//I created a dialog box with id = "IDD_ASK" which include a "Text Box" //with the id = "IDC_NAME" and OK and CANCEL button with the ids "IDOK" //and "IDCANCEL".#include #include
HINSTANCE TheInstance = 0;
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nShowCmd);
LRESULT CALLBACK DialogProc(HWND,UINT,WPARAM,LPARAM);
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nShowCmd)
TheInstance = hInstance;
DialogBox(TheInstance, MAKEINTRESOURCE(IDD_ASK),hDialog, reinterpret_cast(DialogProc));
/*hDialog = CreateDialog(TheInstance,MAKEINTRESOURCE(IDD_ASK),0,(DLGPROC)DialogProc);
while ( GetMessage (&m, NULL, 0, 0 ) )
if (!IsDialogMessage (hDialog, &m))
TranslateMessage ( &m );
DispatchMessage ( &m );
LRESULT CALLBACK DialogProc(HWND hWnd,UINT m,WPARAM wParam,LPARAM lParam)
EndDialog (hWnd, 0);
SendMessage (hWnd, WM_SETTEXT, 0, (LPARAM) buf);
Compiling and Linking: 0 error, 0 warning.
Q: After executing When I clicked over the the text box, window disappears. Why? and How to correct it?
->When I clicked over ok button directly. Message Box appears.
Q: Can you please provide me a code for same(non - MFC). So that I could understand the right way of implementing this.
Q: Program doesn't end in any situation. I have to close it through Task Manager everytime I run it. Why?
And finally, can you please provide me some online tutorials for vc++ (resource programming)