Hey, I am currently using code::blocks and I am basically creating everything by hand here (dialogs and all)

I just need to know how I might go about loading up a dialog that I have created in my .rc (that is, getting it to pop up when I click a button)

I was thinking I could just use some simple thing like ShowDialog() or something along the line (still new to the whole windows gui coding!) but yeah, i've been having quite a bit of trouble trying to solve the mystery of how to actually get this to display when my button is clicked, before I run out of hair from yanking it all out, could someone help me in solving this? lol

Here are my source codes in order.

main.cpp | resource.rc | resource.h
------------------------------------------------------------------------------------


[main.cpp]

#define WIN32_LEAN_AND_MEAN

#include <windows.h>
#include <stdio.h>


#include "resource.h"

/* !>!>!>!>!>!>!>!>!>!>!>!>!>!>!>!>!>!>!>!>!>!>!>!>!>!>!>!>!>!>!>!>!>!>!>
   ! TODO LIST:
   |
   |     1. DLG_SETS1 variables to file (encoded)
   |     2. Utilize DLG_SETS1 variables to login to tools.bisc.cv site
   |     3. Create HTML Scraper to grab and display data
   |     4. API Hook to OMNI? AUTOPOLL INFO HURRAH!
   |
   !>!>!>!>!>!>!>!>!>!>!>!>!>!>!>!>!>!>!>!>!>!>!>!>!>!>!>!>!>!>!>!>!>!>!>

*/


HINSTANCE hInst;

BOOL CALLBACK DialogProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    switch(uMsg)
    {


        case WM_INITDIALOG:
            /*
             * TODO: Add code to initialize the dialog.
             */
            return TRUE;

        case WM_CLOSE:
            EndDialog(hwndDlg, 0);
            return TRUE;

        case WM_COMMAND:
            switch(LOWORD(wParam))
            {
                case IDC_BTN_QUIT:
                    EndDialog(hwndDlg, 0);
                    return TRUE;

                case IDC_BTN_TEST:
                    MessageBox(hwndDlg, "You clicked \"Test\" button!", "Information", MB_ICONINFORMATION);
                    return TRUE;

                case IDC_SETS1:
                        /*
                        * TODO: Add code to initialize the dialog.
                        */
                return TRUE;

                case IDC_SETSBTN:
                /* --> Load Sets Dialog <-- */
                
                
                return TRUE;

                case IDC_EDIT1:
                        /*
                        * TODO: Add code to initialize the dialog.
                        */
                return TRUE;

                case IDC_GETACCT:
                        /*
                        * TODO: Add code to initialize the dialog.
                        */
                return TRUE;

            }
    }

    return FALSE;
}


int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
{
    hInst = hInstance;

    // The user interface is a modal dialog box
    return DialogBox(hInstance, MAKEINTRESOURCE(DLG_MAIN), NULL, DialogProc);
}

------------------------------------------------------------------------------------
[resource.rc]

#include "resource.h"

DLG_MAIN DIALOG DISCARDABLE  0, 0, 239, 200
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "IniTech Tools"
FONT 8, "MS Sans Serif"


// 1st: unknown | 2nd: horizontal | 3rd: vertical | 4th: height |

BEGIN
  LTEXT "Acct:", -1, 2, 3, 45, 8
  CONTROL "&Test", IDC_BTN_TEST, "Button", 0x10010000, 138,  5, 46, 15
  CONTROL "&Quit", IDC_BTN_QUIT, "Button", 0x10010000, 138, 29, 46, 15
  EDITTEXT IDC_EDIT1,/*horizontal*/20, /*vertical*/3,/*width*/55, 10, 18,ES_AUTOHSCROLL
  CONTROL "&GET",  IDC_GETACCT,  "Button", 0x10010000, /*horizontal*/78, /*vertical*/3, /*width*/ 22, /*height*/ 10
  CONTROL "&SETTINGS", IDC_SETSBTN, "Button", 0x10010000, /*horizontal*/200, /*vertical*/3, /*width*/ 38, /*height*/ 10

END

//
// User Settings Dialog
//

DLG_SETS DIALOG DISCARDABLE  0, 0, 239, 200
STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "IniTech Tools - Settings"
FONT 8, "MS Sans Serif"


// 1st: unknown | 2nd: horizontal | 3rd: vertical | 4th: height |

BEGIN
  LTEXT "Bnce:", -1, 2, 3, 45, 8
  CONTROL "&Quit", IDC_BTN_QUIT, "Button", 0x10010000, 138, 29, 46, 15
  EDITTEXT IDC_SETS1,/*horizontal*/20, /*vertical*/3,/*width*/55, 10, 18,ES_AUTOHSCROLL
//  CONTROL "&GET",  IDC_GETACCT,  "Button", 0x10010000, /*horizontal*/78, /*vertical*/3, /*width*/ 22, /*height*/ 10

END

------------------------------------------------------------------------------------
[resource.h]

#include <windows.h>

// ID of Main Dialog
#define DLG_MAIN 101
#define DLG_SETS 102

// ID of Button Controls
#define IDC_BTN_TEST 1001
#define IDC_BTN_QUIT 1002
#define IDC_EDIT1    1003
#define IDC_GETACCT  1004
#define IDC_SETS1    1005
#define IDC_SETSBTN  1006

I just need to know how I might go about loading up a dialog that I have created in my .rc (that is, getting it to pop up when I click a button)

You are doing that very thing already, i.e. using DialogBox(...).
So,
- define a new dialog box resource in the resource files
- write the code for the new dialog procedure
and use it like ...

case IDC_SETSBTN:
/* --> Load Sets Dialog <-- */
    return DialogBox(hInst, MAKEINTRESOURCE(DLG_SETTINGS), 
        hwndDlg, Settings_DialogProc);

>> I am basically creating everything by hand here (dialogs and all)
Doing all that manually, might also result in increased permanent loss of hair, hence I'd suggest that you check out; ResEdit / free Resource Editor for Win32 programs. It's a quite serious application in it's own right.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.