int WindowStructure::InitializeWindow(){
::DialogBoxA(*hInstance,MAKEINTRESOURCEA(IDD_DIALOG1),NULL,WndProc);
return 1;
}
WndProc is a funtion defined as being contained in the class, that is
class WindowStructure{
public::
INT_PTR CALLBACK WndProc();
};
However, i can't get that to work.
When i build it i get this -
'WindowStructure::WndProc': function call missing argument list; use '&WindowStructure::WndProc' to create a pointer to member
So, i use &WindowStructure::WndProc, and that's what i see:
error C2664: 'DialogBoxParamA' : cannot convert parameter 4 from 'INT_PTR (__stdcall WindowStructure::* )(HWND,UINT,WPARAM,LPARAM)' to 'DLGPROC'
So, i set it to return DLGPROC;
And that's where it all goes to hell, as i don't know what to do. As the WndProc (the message loop) returns INT_PTR - TRUE, so i created a DLGPROC object, and returned it. The same error c2664, only with DLGPROC instead of INT_PTR.
iirc, DLGPROC returns BOOL, not INT_PTR. Additionally, you never call DefWindowProc from your dialog proc (if you do, you'll screw a lot of stuff up). Instead, you're supposed to return true if you did something with the message and false if you didn't (in which case the default handling kicks in)
It's been a while since I've done any of this, though, so I might be fuzzy on the details. Try searching MSDN for DLGPROC or DialogProc and see what it says about it.
I don't really understand what you're talking about, Disch. Could you explain in better detail?
Hammurabi: So, i declared it as a static. And it works. However, it 'disconnects' the function from the class. The result is, i have to declare EVERYTHING as static there. Every single variable, every single object and every single function that's contained in the class i have to declare as static.
Granted, i don't really understand the static as for now, i'm still learning c/c++, but why it forces me to declare everything as static? And is there a way to bypass this? The 'readability' of code is somewhat compromised when i have a large block of variable declarations at the beginning of the WindowStructure.cpp. It just looks bad.
class WindowStructure
{
public:
WindowStructure();
~WindowStructure();
int Init(HINSTANCE*);
int InitializeWindow();
static int prepareVariables();
static int openFile(int);
static int openBitmap();
static int refreshPictureControl();
static int convertCToArray();
static int saveMap();
static int getNewScrollInformation();
static int captureMouseClick();
static int verticalOffset, horizontalOffset; // Picture-in-a-box offset to copy from source to piccontrol
static int maxVerticalOffset, maxHorizontalOffset; // Maximum offset that can be used to copy from source to piccontrol
static int pictureControlWidth, pictureControlHeight; // self-explanatory
static int pictureControlX, pictureControlY; // containst the location of the picture relative to the window
static int mouseClickX,mouseClickY; //self-explanatory.
static int relativeMouseClickX,relativeMouseClickY; // mouse click translated to the relative point in the picture
static int chosenChipsetX,chosenChipsetY; // chosen chipset when clicked in the picture;l\
Here's what's going on when i'm declaring something as non-static. I un-staticked the relativemouseclickY in the captureMouseClick above -
Two errors pops that says : "
error C2597: illegal reference to non-static member 'WindowStructure::relativeMouseClickY'
error C3867: 'WindowStructure::relativeMouseClickY': function call missing argument list; use '&WindowStructure::relativeMouseClickY' to create a pointer to member
So, i don't have the foggiest idea what's going on. I can submit the whole project if requested. Nothing important, really, something i'm writing to learn WinAPI
Ok, i figured that one out, thanks to you, Hammurabi.
I've made a static pointer to the object, then i just used the pointer within the static function.
And i think i've learned something new today.