If you make a form in the resource editor thing named IDD_FORMSHOW, how do you tell the form to be visible in the int main function?
Printable View
If you make a form in the resource editor thing named IDD_FORMSHOW, how do you tell the form to be visible in the int main function?
I could show you how to do it through pure API :p
Yeah but i am not ready for that yet...i'm trying to start out very slowly...go with the easy way first...so how do I make the form visible?
I've never used MFC but possible the ShowWindow() API would work. But you'd need to have the hWnd of your window for that to work.
Instead of using int main(), you might have to use int WINAPI WinMain(). Not sure though.
Using resource dialogs
I think that is what you are looking for.
:)
Yeah i meant WinMain..um...and i tried the showwindow, but i didnt know how to pass the hWnd...
I'll check out that site, thanks.
when i use that example:
Code:#include <windows.h>
#include "resource.h"
HWND ghWnd_Main = 0;
INT_PTR CALLBACK DlgProc(HWND hWndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam) {
switch(uMsg) {
case WM_COMMAND:
if(LOWORD(wParam) == IDC_BTN_CANCEL) {
MessageBox(hWndDlg, "Cancel pressed!", "Button", MB_OK);
}
if(LOWORD(wParam) == IDC_BTN_OK) {
MessageBox(hWndDlg, "OK pressed!", "Button", MB_OK);
}
return FALSE;
case WM_CLOSE:
EndDialog(hWndDlg, 0);
PostQuitMessage(0);
break;
}
return FALSE;
}
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
if((ghWnd_Main = CreateDialog(hInstance, MAKEINTRESOURCE(IDD_MAIN), NULL, DlgProc)), ghWnd_Main) {
ShowWindow(ghWnd_Main, nCmdShow);
} else {
MessageBox(NULL, "Could not create dialogue box", "Error", MB_OK);
}
MSG msg;
int lRes;
for(;;) {
lRes = GetMessage(&msg, NULL, NULL, NULL);
if(lRes == 0 || lRes == -1)
break;
DispatchMessage(&msg);
}
return msg.wParam;
}
it keeps saying this error:
what do i do? :confused:Quote:
C:\downloads\RawDlg\rawdlg.cpp(26) : error C2664: 'CreateDialogParamA' : cannot convert parameter 4 from 'long (struct HWND__ *,unsigned int,unsigned int,long)' to 'int (__stdcall *)(struct HWND__ *,unsigned int,unsigned int,long)'
None of the functions with this name in scope match the target type
Error executing cl.exe.
That's my code there, so you'd need the Platform SDK installed...
Either that, or change the INT_PTR to LRESULT...