hello i have one more little prob i cant sort i wont to make a program that uses forms i have created in the resource part of VS6 i have created a few forms and i can get the main to work by using
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
return DialogBox(hInstance, MAKEINTRESOURCE(Frm_Main), NULL, DlgProc);
}
but what i wont to do is have a button that opens more over the top of that for options and stuf is this possible using the way a create my main on or am i doing it complelty the wrong way
finding it hard to find desent tutorials :) thx for any help.
kirants
October 25th, 2004, 07:32 PM
The common way to do it is in first dialog's callback, i.e. DlgProc, you add a handler for WM_COMMAND with ID = button ID, and do a DialogBox for the other form.
Theone2k
October 25th, 2004, 07:42 PM
yeah i have a WM_COMMAND and have all the buttons on that forum working. what i wont to do is click a connect button then a dialog box appears asking for address and port what i dont understand is how on the button press i get it to show the other dialog box
case WM_COMMAND:
{
switch(LOWORD(wParam))
{
case BTN_CONNECT:
{
//wont to call connect form here
}
}
i have tried calling it the same as the main one butt that doesnt work and is there an easy way to do it or could you point me somewere that coulde explain it?
kirants
October 25th, 2004, 07:45 PM
You are in the right track:
case BTN_CONNECT:
{
int nRet = DialogBox(hInstance, MAKEINTRESOURCE(Connect_Dialog_template_ID), NULL, ConnectDlgProc);
}
Theone2k
October 25th, 2004, 07:52 PM
yeah i tried something simmerla to that but when i try it i get
error C2065: 'hInstance' : undeclared identifier
do i have to pass it from the main some how?
im very new to win programming :)
kirants
October 25th, 2004, 07:59 PM
What is generally done is:
1. have a global variable HINSTANCE g_hInstance;
2. Set it to NULL
3. In WinMain, one of the first things to do is to
g_hInstance = [hInstance passed in WinMain];
4. In future, wherever you need to pass the instance handle, use g_hInstance.
Theone2k
October 25th, 2004, 08:21 PM
well this now seems to work
it compiles and runs, I click the connect button button but nothing happens do i need some code to draw it to the screen?