Windows 2X

Hi all,

I wrote a message (rather important) and I think it's gotten lost somewhere in the sands of time. Here it is:

": Hi all,
:
: Can someone either send me a simple program or tutorial that shows me how to launch a 2nd window from a button on the main window?
:
: Thanks,
: Hungry J.
:
When the WM_COMMAND message is received with wparam (3rd parameter) equal to the Control ID of the button, then just create the new window with CreateWindowEx.

Thanks for the advice but I'm not entirely clear on it. The first thing I must explain is I'm a beginner and don't know all the C++ terms. But what you're saying is simply to use CreateWindowEx during the button-click line (like where you can tell it to open up a message box). Could you give me an example of the code from the point where you tell the program:
"Do this when this button is clicked down" to using CreateWindowEx?

Thanks,
Hungry J. "

Can someone help me with this?

Thanks,
Hungry J




Comments

  • : Hi all,
    :
    : I wrote a message (rather important) and I think it's gotten lost somewhere in the sands of time. Here it is:
    :
    : ": Hi all,
    : :
    : : Can someone either send me a simple program or tutorial that shows me how to launch a 2nd window from a button on the main window?
    : :
    : : Thanks,
    : : Hungry J.
    : :
    : When the WM_COMMAND message is received with wparam (3rd parameter) equal to the Control ID of the button, then just create the new window with CreateWindowEx.
    :
    : Thanks for the advice but I'm not entirely clear on it. The first thing I must explain is I'm a beginner and don't know all the C++ terms. But what you're saying is simply to use CreateWindowEx during the button-click line (like where you can tell it to open up a message box). Could you give me an example of the code from the point where you tell the program:
    : "Do this when this button is clicked down" to using CreateWindowEx?
    :
    : Thanks,
    : Hungry J. "
    :
    : Can someone help me with this?
    :
    : Thanks,
    : Hungry J
    :
    : you can download or search on menu in search.
    you can get many item on it.
    good luck.
    :
    :




  • : : Hi all,
    : :
    : : I wrote a message (rather important) and I think it's gotten lost somewhere in the sands of time. Here it is:
    : :
    : : ": Hi all,
    : : :
    : : : Can someone either send me a simple program or tutorial that shows me how to launch a 2nd window from a button on the main window?
    : : :
    : : : Thanks,
    : : : Hungry J.
    : : :
    : : When the WM_COMMAND message is received with wparam (3rd parameter) equal to the Control ID of the button, then just create the new window with CreateWindowEx.
    : :
    : : Thanks for the advice but I'm not entirely clear on it. The first thing I must explain is I'm a beginner and don't know all the C++ terms. But what you're saying is simply to use CreateWindowEx during the button-click line (like where you can tell it to open up a message box). Could you give me an example of the code from the point where you tell the program:
    : : "Do this when this button is clicked down" to using CreateWindowEx?
    : :
    : : Thanks,
    : : Hungry J. "
    : :
    : : Can someone help me with this?
    : :
    : : Thanks,
    : : Hungry J
    : :
    : : you can download or search on menu in search.
    : you can get many item on it.
    : good luck.
    : :
    : :

    Do you mean search on something like Yahoo?


  • : : : Hi all,
    : : :
    : : : I wrote a message (rather important) and I think it's gotten lost somewhere in the sands of time. Here it is:
    : : :
    : : : ": Hi all,
    : : : :
    : : : : Can someone either send me a simple program or tutorial that shows me how to launch a 2nd window from a button on the main window?
    : : : :
    : : : : Thanks,
    : : : : Hungry J.
    : : : :
    : : : When the WM_COMMAND message is received with wparam (3rd parameter) equal to the Control ID of the button, then just create the new window with CreateWindowEx.
    : : :
    : : : Thanks for the advice but I'm not entirely clear on it. The first thing I must explain is I'm a beginner and don't know all the C++ terms. But what you're saying is simply to use CreateWindowEx during the button-click line (like where you can tell it to open up a message box). Could you give me an example of the code from the point where you tell the program:
    : : : "Do this when this button is clicked down" to using CreateWindowEx?
    : : :
    : : : Thanks,
    : : : Hungry J. "
    : : :
    : : : Can someone help me with this?
    : : :
    : : : Thanks,
    : : : Hungry J
    : : :
    : : : you can download or search on menu in search.
    : : you can get many item on it.
    : : good luck.
    : : :
    : : :
    :
    : Do you mean search on something like Yahoo?
    : i mean you can search on
    "programmersheaven.com.
    :




  • : : : : Hi all,
    : : : :
    : : : : I wrote a message (rather important) and I think it's gotten lost somewhere in the sands of time. Here it is:
    : : : :
    : : : : ": Hi all,
    : : : : :
    : : : : : Can someone either send me a simple program or tutorial that shows me how to launch a 2nd window from a button on the main window?
    : : : : :
    : : : : : Thanks,
    : : : : : Hungry J.
    : : : : :
    : : : : When the WM_COMMAND message is received with wparam (3rd parameter) equal to the Control ID of the button, then just create the new window with CreateWindowEx.
    : : : :
    : : : : Thanks for the advice but I'm not entirely clear on it. The first thing I must explain is I'm a beginner and don't know all the C++ terms. But what you're saying is simply to use CreateWindowEx during the button-click line (like where you can tell it to open up a message box). Could you give me an example of the code from the point where you tell the program:
    : : : : "Do this when this button is clicked down" to using CreateWindowEx?
    : : : :
    : : : : Thanks,
    : : : : Hungry J. "
    : : : :
    : : : : Can someone help me with this?
    : : : :
    : : : : Thanks,
    : : : : Hungry J
    : : : :
    : : : : you can download or search on menu in search.
    : : : you can get many item on it.
    : : : good luck.
    : : : :
    : : : :
    : :
    : : Do you mean search on something like Yahoo?
    : : i mean you can search on
    : "programmersheaven.com.
    : :
    :
    :
    :
    :


    I couln't find any VC++ Win32 tutorials does anyone know of any good ones? If not, can you just show me how to luanch the window (the above text)?

    Thanks
    Hungry J,

  • 1: In VC resource editor. Create a new dialog (choose "Insert Dialog" in the Dialog Menu in the tree to the left) and create a new class for it (you will be asked to do so when entering the Class Wizard by pressing Ctrl+w in the dialog editor). For instance CNewDialog.
    2: Go to the other dialog (with the button) on the resource editor. Double click the button. A window pops up asking you what to call the handler. Click OK.
    3: You should now be in the code editor.
    [code]
    void CSomeClassOfYour::OnButton1()
    {
    CNewDialog Dlg;

    if(Dlg.DoModal()!=IDOK) return;

    MessageBox("You pressed OK in CNewDialog");
    }
    [/code]
    4: In the top of the file, you will have to include the header file for the new dialog - so that the compiler knows what a CNewDialog is:
    [code]
    [blue]#include "NewDialog.h"[/blue]
    [/code]


  • This topic is really OLD! I remember sending to Hungry J some files, but looks like it was to no avail... You teaching him MFC, but instead he should understand the "event driven" programming - Windows basics, so to speak. How to intercept these events and what involved in creating a window...


  • Ok, here's an example.

    [/code]
    #include

    HINSTANCE hinstance;
    int wcount=1;
    long CALLBACK bah(HWND win,UINT msg,WPARAM wparam,LPARAM lparam)
    {
    switch(msg) {
    case WM_CREATE:
    CreateWindowEx(0,"BUTTON","Press this button",WS_VISIBLE,20,20,150,20,win,(HMENU)3000,hinstance,0);
    break;
    case WM_COMMAND:
    if(wparam==3000) {
    CreateWindowEx(0,"BAH","Bah!",WS_VISIBLE|WS_OVERLAPPEDWINDOW|WS_CLIPSIBLINGS|WS_CLIPCHILDREN,0,0,400,400,0,0,hinstance,0);
    wcount++;
    }
    break;
    case WM_DESTROY:
    if(!--wcount) PostQuitMessage(0);
    break;
    default: return DefWindowProc(win,msg,wparam,lparam);
    }
    }

    int WINAPI WinMain(HINSTANCE hinst,HINSTANCE previnst,LPSTR cmdline,int cmdshow)
    {
    WNDCLASS wc={0,bah,0,0,hinst,0,0,GetStockObject(BLACK_BRUSH),0,"BAH"};
    MSG msg;
    RegisterClass(&wc);
    hinstance=hinst;
    CreateWindowEx(0,"BAH","Bah!",WS_VISIBLE|WS_OVERLAPPEDWINDOW|WS_CLIPSIBLINGS|WS_CLIPCHILDREN,0,0,400,400,0,0,hinst,0);
    while(GetMessage(&msg,0,0,0)) {
    TranslateMessage(&msg);
    DispatchMessage(&msg);
    }
    return 0;
    }
    [/code]

  • : 1: In VC resource editor. Create a new dialog (choose "Insert Dialog" in the Dialog Menu in the tree to the left) and create a new class for it (you will be asked to do so when entering the Class Wizard by pressing Ctrl+w in the dialog editor). For instance CNewDialog.
    : 2: Go to the other dialog (with the button) on the resource editor. Double click the button. A window pops up asking you what to call the handler. Click OK.
    : 3: You should now be in the code editor.
    : [code]
    : void CSomeClassOfYour::OnButton1()
    : {
    : CNewDialog Dlg;
    :
    : if(Dlg.DoModal()!=IDOK) return;
    :
    : MessageBox("You pressed OK in CNewDialog");
    : }
    : [/code]
    : 4: In the top of the file, you will have to include the header file for the new dialog - so that the compiler knows what a CNewDialog is:
    : [code]
    : [blue]#include "NewDialog.h"[/blue]
    : [/code]
    :
    :

    Okay, I've done all that but I've got two errors:


    --------------------Configuration: Go - Win32 Debug--------------------
    Compiling...
    dialogone.cpp
    C:My DocumentsGodialogone.cpp(5) : fatal error C1083: Cannot open include file: 'gores.h': No such file or directory
    dialogtwo.cpp
    C:My DocumentsGodialogtwo.cpp(5) : fatal error C1083: Cannot open include file: 'gores.h': No such file or directory
    Generating Code...
    Error executing cl.exe.

    Go.exe - 2 error(s), 0 warning(s)

    -------------

    These are probably easy problems to solve but I am new to this so please be patient. Can you help?

    Thanks,
    Hunrgy J

    PS. Sephiroth2 - thanks for the code but I'm going to work on this one for now.


  • : Compiling...
    : dialogone.cpp
    : C:My DocumentsGodialogone.cpp(5) : fatal error C1083: Cannot open include file: 'gores.h': No such file or directory
    : dialogtwo.cpp
    : C:My DocumentsGodialogtwo.cpp(5) : fatal error C1083: Cannot open include file: 'gores.h': No such file or directory
    : Generating Code...
    : Error executing cl.exe.
    :
    : Go.exe - 2 error(s), 0 warning(s)
    :
    : -------------

    It seems to me that you have tried to include a file that doesn't exist. Did you name anything "gores" yourself? And do you need it? If not, simply remove the include directive for it. If so, check the directories/paths

  • : This topic is really OLD! I remember sending to Hungry J some files, but looks like it was to no avail... You teaching him MFC, but instead he should understand the "event driven" programming - Windows basics, so to speak. How to intercept these events and what involved in creating a window...
    :

    True - but earlier on he posted that he was looking for VC++ tutorials.

    I do agree that using MFC/VC++ without knowing what it all does for real can turn out to be problematic. But then again: It's never too late to learn the building block of the high level language. I learned C/C++ before assembly - and knowing what the compiler generates and how the CPU works has of course made me a better designer/programmer. However, that doesn't mean that my early C/C++ programs didn't work. They could've just been programmed harder/better/faster/stronger [sorry :-)]

    But all this is sort of Off Topic, so I'd better end here.


  • : : Compiling...
    : : dialogone.cpp
    : : C:My DocumentsGodialogone.cpp(5) : fatal error C1083: Cannot open include file: 'gores.h': No such file or directory
    : : dialogtwo.cpp
    : : C:My DocumentsGodialogtwo.cpp(5) : fatal error C1083: Cannot open include file: 'gores.h': No such file or directory
    : : Generating Code...
    : : Error executing cl.exe.
    : :
    : : Go.exe - 2 error(s), 0 warning(s)
    : :
    : : -------------
    :
    : It seems to me that you have tried to include a file that doesn't exist. Did you name anything "gores" yourself? And do you need it? If not, simply remove the include directive for it. If so, check the directories/paths
    :

    I'm sure I need the file, I get 26 errors if it's not there. When I click on the resource tabs the folder with all the dialogs and whatnot is called "gores". Is there a way to make this gores.h file? I've got a "gores.rc" file but now .h file. Also, in the FileView there are no files in the "Resource" folder. Does this help identify the problem?

    -Hungry J


  • What errors do you get if it is not included?

    Have you got a file named "resource.h" included?



  • : What errors do you get if it is not included?
    :
    : Have you got a file named "resource.h" included?
    :
    :
    :

    I didn't have resource.h included but even when i included it I got these errors:


    c:my documentsgodialogone.h(14) : error C2504: 'CDialog' : base class undefined
    c:my documentsgodialogone.h(17) : error C2629: unexpected 'class dialogone ('
    c:my documentsgodialogone.h(17) : error C2238: unexpected token(s) preceding ';'
    c:my documentsgodialogone.h(30) : error C2061: syntax error : identifier 'CDataExchange'
    c:my documentsgodialogone.h(41) : error C2143: syntax error : missing ';' before '}'
    c:my documentsgodialogtwo.h(14) : error C2504: 'CDialog' : base class undefined
    c:my documentsgodialogtwo.h(17) : error C2629: unexpected 'class dialogtwo ('
    c:my documentsgodialogtwo.h(17) : error C2238: unexpected token(s) preceding ';'
    c:my documentsgodialogtwo.h(30) : error C2061: syntax error : identifier 'CDataExchange'
    c:my documentsgodialogtwo.h(41) : error C2143: syntax error : missing ';' before '}'
    C:My DocumentsGodialogone.cpp(19) : error C2065: 'CWnd' : undeclared identifier
    C:My DocumentsGodialogone.cpp(19) : error C2065: 'pParent' : undeclared identifier
    C:My DocumentsGodialogone.cpp(20) : error C2448: '' : function-style initializer appears to be a function definition
    C:My DocumentsGodialogone.cpp(20) : error C2143: syntax error : missing ';' before ':'
    C:My DocumentsGodialogone.cpp(21) : error C2448: '' : function-style initializer appears to be a function definition
    C:My DocumentsGodialogone.cpp(28) : error C2065: 'CDataExchange' : undeclared identifier
    C:My DocumentsGodialogone.cpp(28) : error C2065: 'pDX' : undeclared identifier
    C:My DocumentsGodialogone.cpp(29) : error C2448: '' : function-style initializer appears to be a function definition
    C:My DocumentsGodialogone.cpp(37) : error C2061: syntax error : identifier 'CDialog'
    C:My DocumentsGodialogone.cpp(40) : error C2146: syntax error : missing ';' before identifier 'END_MESSAGE_MAP'
    C:My DocumentsGodialogone.cpp(40) : fatal error C1004: unexpected end of file found
    dialogtwo.cpp
    C:My DocumentsGodialogtwo.cpp(5) : fatal error C1083: Cannot open include file: 'gores.h': No such file or directory
    Generating Code...
    Error executing cl.exe.

    Go.exe - 22 error(s), 0 warning(s)

    Would it be easier if I sent this to you to asses?



Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories