c++ - Trying to produce a window
- Peter (38/38) Dec 08 2002 Hi all,
- Tempest (11/49) Dec 08 2002 Hi Peter,
- Peter (15/15) Dec 08 2002 Walter,
- Walter (8/23) Dec 08 2002 You'll need a file called "program.def" in it, and it should contain the
- Walter (4/42) Dec 08 2002 What's your .def file?
- Daniel Fazekas (23/61) Dec 22 2002 How are you compiling in the resource?
Hi all, Still Struggling! I'm trying to produce a simple window. It compiles OK but nothing seems to happen! Am I trying to achieve the impossible or am I doing something totally wrong?... Peter. --------------------------------------------------------- #include <windows.h> #include <tchar.h> #include "resource.h" BOOL MainDialogProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { return FALSE; } int _tmain(void) { DialogBoxParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_DIALOG1), NULL, (DLGPROC)MainDialogProc, 0); return 0; } ------------------------------------------------------------- This is the resource.h file: ------------------------------------------------------------- //{{NO_DEPENDENCIES}} // Microsoft Developer Studio generated include file. // Used by Step1.rc // #define IDD_DIALOG1 101 // Next default values for new objects // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 102 #define _APS_NEXT_COMMAND_VALUE 40001 #define _APS_NEXT_CONTROL_VALUE 1000 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif
Dec 08 2002
Hi Peter, I think returing FALSE from the DLGPROC might be the problem. The DLGPROC handles all messages, which include things such as creation and initialisation of the dialog. Returning FALSE would indicate failure and terminate your processing prematurely. Try to find a default function to call, replacing return FALSE with something like: return DefWindowProc (hWnd, uMsg, wParam, lParam); Anton. "Peter" <Peter_member pathlink.com> wrote in message news:asvniv$2b4i$1 digitaldaemon.com...Hi all, Still Struggling! I'm trying to produce a simple window. It compiles OK but nothing seems to happen! Am I trying to achieve the impossible or am I doing somethingtotallywrong?... Peter. --------------------------------------------------------- #include <windows.h> #include <tchar.h> #include "resource.h" BOOL MainDialogProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { return FALSE; } int _tmain(void) { DialogBoxParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_DIALOG1), NULL, (DLGPROC)MainDialogProc, 0); return 0; } ------------------------------------------------------------- This is the resource.h file: ------------------------------------------------------------- //{{NO_DEPENDENCIES}} // Microsoft Developer Studio generated include file. // Used by Step1.rc // #define IDD_DIALOG1 101 // Next default values for new objects // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 102 #define _APS_NEXT_COMMAND_VALUE 40001 #define _APS_NEXT_CONTROL_VALUE 1000 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif
Dec 08 2002
Walter, Sorry for my ignorange but could you explain what .def file is needed? When the cd arrives I'll probably have some reading to do!. Anton, I've tried many variations but with no luck. In fact I haven't yet managed to get a non-console program to work!. Below is the most minimal program that if I understand correctly should work without invoking the console but it does. I think I must be making some mistake while compiling... #include <windows.h> int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) { MessageBox(NULL, "Hello world!", "Sample", MB_OK); return 0; } Peter.
Dec 08 2002
You'll need a file called "program.def" in it, and it should contain the line: EXETYPE WINDOWS "Peter" <Peter_member pathlink.com> wrote in message news:at0ceq$6up$1 digitaldaemon.com...Walter, Sorry for my ignorange but could you explain what .def file is needed? When the cd arrives I'll probably have some reading to do!. Anton, I've tried many variations but with no luck. In fact I haven't yet managedtoget a non-console program to work!. Below is the most minimal program thatif Iunderstand correctly should work without invoking the console but it does.Ithink I must be making some mistake while compiling... #include <windows.h> int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) { MessageBox(NULL, "Hello world!", "Sample", MB_OK); return 0; } Peter.
Dec 08 2002
What's your .def file? "Peter" <Peter_member pathlink.com> wrote in message news:asvniv$2b4i$1 digitaldaemon.com...Hi all, Still Struggling! I'm trying to produce a simple window. It compiles OK but nothing seems to happen! Am I trying to achieve the impossible or am I doing somethingtotallywrong?... Peter. --------------------------------------------------------- #include <windows.h> #include <tchar.h> #include "resource.h" BOOL MainDialogProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { return FALSE; } int _tmain(void) { DialogBoxParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_DIALOG1), NULL, (DLGPROC)MainDialogProc, 0); return 0; } ------------------------------------------------------------- This is the resource.h file: ------------------------------------------------------------- //{{NO_DEPENDENCIES}} // Microsoft Developer Studio generated include file. // Used by Step1.rc // #define IDD_DIALOG1 101 // Next default values for new objects // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 102 #define _APS_NEXT_COMMAND_VALUE 40001 #define _APS_NEXT_CONTROL_VALUE 1000 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif
Dec 08 2002
How are you compiling in the resource? Show us the .rc file too. Is the .res file getting generated correctly and is it linked into your executable? Check if the return value of DialogBoxParam is -1 and if so, try to output the error message from Windows. if (DialogBoxParam(....) == -1) { LPTSTR lpMsgBuf; FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) & lpMsgBuf, 0, NULL); MessageBox(NULL, (LPCTSTR) lpMsgBuf, TEXT("Error"), MB_OK | MB_ICONSTOP); LocalFree(lpMsgBuf); } -- Daniel "Peter" <Peter_member pathlink.com> wrote in message news:asvniv$2b4i$1 digitaldaemon.com...Hi all, Still Struggling! I'm trying to produce a simple window. It compiles OK but nothing seems to happen! Am I trying to achieve the impossible or am I doing somethingtotallywrong?... Peter. --------------------------------------------------------- #include <windows.h> #include <tchar.h> #include "resource.h" BOOL MainDialogProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { return FALSE; } int _tmain(void) { DialogBoxParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_DIALOG1), NULL, (DLGPROC)MainDialogProc, 0); return 0; } ------------------------------------------------------------- This is the resource.h file: ------------------------------------------------------------- //{{NO_DEPENDENCIES}} // Microsoft Developer Studio generated include file. // Used by Step1.rc // #define IDD_DIALOG1 101 // Next default values for new objects // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 102 #define _APS_NEXT_COMMAND_VALUE 40001 #define _APS_NEXT_CONTROL_VALUE 1000 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif
Dec 22 2002