Application Class & HWND

EDIT:
I've solved it. I've just created a new instance of the class in the message handler and called the method... Not the best way, but it does it's work!
------------------------------------

Hello,
it's me again. At the moment I'm learning to program with the winAPI. I'm making a window and a simple edit box for which I've made a class. My problem is now, that I can't assign the window handle to the edit box. I've searched for hours and haven't found anything helpful.

Here's my code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*************************************************************
 * The Application Class
 *************************************************************/
class CApplication
{
private:
	/* Member Variables */
	HWND							hWnd;
	HWND							editMain;

	/* Member Methods */
	static LRESULT CALLBACK			WndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam );
	bool							CreateControls( HWND hWnd, HINSTANCE hInst );
	// Making this function static causes a problem with the member
	// variables... Making them static as well causes also an error!

public:
	/* Member Methods */
	CApplication( void );
	~CApplication( void );

	bool							Init( HINSTANCE hInst );
	inline HWND						GetMainWnd( void );
};

/*************************************************************
 * Message Handler
 *************************************************************/
LRESULT CALLBACK CApplication::WndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ) {
	CApplication appTmp;
	switch( msg ) {
	case WM_CREATE:
		{
			appTmp.CreateControls( hWnd, ((LPCREATESTRUCT)lParam)->hInstance );
			break;
		}
	case WM_CLOSE:
	case WM_DESTROY:
		{
			PostQuitMessage( 0 );
			break;
		}
	default:
		{
			return DefWindowProc( hWnd, msg, wParam, lParam );
		}
	}
	return 0;
}

/*************************************************************
 * Create the controls
 *************************************************************/
bool CApplication::CreateControls( HWND hWnd, HINSTANCE hInst ) {
	editMain = CreateWindowEx( WS_EX_CLIENTEDGE, "edit", "Test",
		WS_CHILD | WS_VISIBLE | WS_BORDER |
		ES_MULTILINE |
		WS_HSCROLL | WS_VSCROLL,
		0, 0, 600, 400,
		hWnd, (HMENU)IDM_EDIT_TEST, hInst, NULL );
	if( !editMain )
		return false;
	return true;
}


I bet it's something simple I'm missing here...
Thanks for any help in advance!

Sincerly


DarkDragon1993
Last edited on
Topic archived. No new replies allowed.