C + WinAPI: Creating A "Static" Like Class Which Allows Me To Update Caption
I am trying to make a small program in C and Windows API and I need to update some text in a static control. I have read that changing static's text at runtime is not possible and I have to duplicate the class and make one according to requirement. The problem is, how do I duplicate the class. I am a beginner and below is the current class attributes I have(which is of course, for a window!). What changes are needed for such a control? Or if it is too much work,should I use a text box(unchangable by user) instead?
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.lpszClassName = TEXT( "Window" );
wc.hInstance = hInstance ;
wc.hbrBackground = (HBRUSH)(COLOR_WINDOW);
wc.lpszMenuName = NULL;
wc.lpfnWndProc = WndLogProc;
wc.hCursor = LoadCursor(NULL, IDC_AR开发者_如何学JAVAROW);
Who told you that it's not possible to change a static window's text? If you use SetWindowText
you can change the contents. It will not display those new contents automatically, but you can force the window to redraw with RedrawWindow
.
P.S. You should be using a class type of "static" for a static control, not "Window". The list of built-in window classes is here in MSDN.
精彩评论