Sign in to follow this  

[Win32 / C++] More problems with windows controls - Edit control not responsive

This topic is 2635 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Okay, so I set up a control like so:

  HWND hcEdit = CreateWindowEx(0, WC_EDIT, 0, WS_VISIBLE|WS_CHILD|WS_TABSTOP|WS_BORDER|ES_AUTOHSCROLL, 141, 250, 375, 33, hwnd, (HMENU)IDC_EDIT, hInstance, 0);
SendMessage(hcEdit, WM_SETFONT, (WPARAM)hfont0, FALSE);
SendMessage(hcEdit, EM_LIMITTEXT, (WPARAM)150, 0);


And then I have this button that I want to clear the text in the control when I press it. So here's my window proc:

char empty_string[] = "";

LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
switch(msg) {
case WM_COMMAND:
if((LOWORD(wParam) == IDC_BUTTON) && (HIWORD(wParam) == BN_CLICKED)) {
/*clear edit box*/
Edit_SetText(hcEdit, empty_string);
}
break;
case WM_CLOSE: DestroyWindow(hwnd); break;
case WM_DESTROY: PostQuitMessage(0); break;
}
return DefWindowProc(hwnd, msg, wParam, lParam);
}


I've also tried sending the WM_SETTEXT message, but both methods fail to clear the text. Am I missing something again? (Why is this stuff so complicated?)

Thank you in advance for any advice. :)

----------------------------------------------------------------
EDIT:

I am a pillock. I declared the control handles globally but then in WinMain I redeclared them locally, so the controls weren't being created in the correct scope. -.-

Realized it just after I posted. Sorry.

Share this post


Link to post
Share on other sites

This topic is 2635 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this