-
ALMOST THERE!
Updates Source
Code:
#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_DialogBox),
NULL, (DLGPROC)MainDialogProc, 0);
return 0;
}
Updated Header
Code:
#include <windows.h>
#define IDD_DialogBox 100
Compiler Errors:
/Documents and Settings/Owner/Desktop/Comp Prog/C++/Windows API Lessons/Lesson2/example1.cpp C:\Documents and Settings\Owner\Desktop\Comp Prog\C++\Windows API Lessons\Lesson2\C resource.h: No such file or directory.
In function `int main()':
12 C:\Documents and Settings\Owner\Desktop\Comp Prog\C++\Windows API Lessons\Lesson2\example1.cpp ` IDD_DialogBox' undeclared (first use this function)
Ive added the heder file into the directory, perhpas i should move the header file to where all the others are? Into the dev folder?
-
#include "resource.h"
if you use < and > then the compiler thinks to look into the default include directory.
-
Ok, so im almost there!!!!
remade source again
Code:
#include <windows.h>
#include <tchar.h>
#include <resource.hpp>
BOOL MainDialogProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
return FALSE;
}
int _tmain(void)
{
DialogBoxParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_DialogBox),
NULL, (DLGPROC)MainDialogProc, 0);
return 0;
}
remade header file
saved as resource.hpp and not resource.h
1 error left to tackle!
26 C:\Documents and Settings\Owner\Desktop\Comp Prog\C++\Windows API Lessons\Lesson2\resource.hpp:5 [Warning] no newline at end of file
-
That's a warning, not an error. Go to the very end of the file and hit enter once.
-
Ok, no errors compiling, but when nothing shows up!!!
Code:
#include <windows.h>
#include <tchar.h>
#include <resource.hpp>
BOOL MainDialogProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
return FALSE;
}
int _tmain(void)
{
DialogBoxParam(GetModuleHandle(NULL), MAKEINTRESOURCE(IDD_DialogBox),
NULL, (DLGPROC)MainDialogProc, 0);
return 0;
}
Perhaps it has something to do with the res file?
-
No, I believe it has something to do with the MainDialogProc always returning FALSE. There are some messages sent that, if you return FALSE, prevent the creation of the dialog in the first place.
Return TRUE in all cases instead.
You might also want to check the return value of DialogBoxParam to see if it gives you an error code. And check GetLastError().