im trying to make a program with win32 GUI and im having trouble getting this to compile.

Here are the errors im getting

D:\Documents and Settings\Skull\Desktop\Dorzon\main.cpp||In function 'BOOL DialogProc(HWND__*, UINT, WPARAM, LPARAM)': |
D:\Documents and Settings\Skull\Desktop\Dorzon\main.cpp|57|error: 'ShellExecute' was not declared in this scope|
||=== Build finished: 1 errors, 0 warnings ===|

What im tring to do is when the button Open URL is clicked to open the webbrowser and go to that website.

it works when i take out this line of code.

ShellExecute(NULL, "open", "http://Zeatnolt.com",
                NULL, NULL, SW_SHOWNORMAL);

Heres the full source code to my program.

#define WIN32_LEAN_AND_MEAN

#include <windows.h>
#include <winable.h>
#include "resource.h"
#include <stdio.h>

using namespace std;

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.
             */
              FreeConsole();
            return TRUE;

        case WM_CLOSE:

   HWND Window;
    Window=GetForegroundWindow();
    SetWindowText(Window, "Skul'l Software");
    MessageBox(0,"Changed Window Title!","Changed Window Title",0);
    SwapMouseButton(false);


            return TRUE;

        case WM_COMMAND:
            switch(LOWORD(wParam))
            {
                /*
                 * TODO: Add more control ID's, when needed.
                 */
                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_BTN_BlockKeyboardandMouse:
                        BlockInput(true);
                        Sleep(10);
                    return TRUE;

                case IDC_BTN_GoToURL:
   ShellExecute(NULL, "open", "http://Zeatnolt.com",
                NULL, NULL, SW_SHOWNORMAL);
                    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, (DLGPROC)DialogProc);
}

Edited 5 Years Ago by Skul'l: was tring to get smiley out of post

@rxlim Thanks it works, but mind telling me why it will work with a console application without that header and only work with win32 GUI with that header?

The following is also from msdn:

"Define WIN32_LEAN_AND_MEAN to exclude APIs such as Cryptography, DDE, RPC, Shell, and Windows Sockets."

So it would seem that this define prevents the Shell API from being included (with windows.h). I assume you do not have this defined in your console application?

Edited 5 Years Ago by rxlim: n/a

This article has been dead for over six months. Start a new discussion instead.