Jump to content
  • Advertisement
Sign in to follow this  
Khatharr

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

This topic is 2824 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
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!