Hi
Is it possible to change a classname during runtime?
For example:
I have created a single line static control... during runtime convert the static into a edit control, preserving same x,y,w,h dimensions.
This is a discussion on Change a control class during runtime within the Windows Programming forums, part of the Platform Specific Boards category; Hi Is it possible to change a classname during runtime? For example: I have created a single line static control... ...
Hi
Is it possible to change a classname during runtime?
For example:
I have created a single line static control... during runtime convert the static into a edit control, preserving same x,y,w,h dimensions.
* Debian 6.0.1 on Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM.
* lighttpd, php5, perl, eruby, python.
* geany, XHTML & CSS & JavaScript, C, C++.
* GTK+ C & perl-gtk2
1. Get the position of the control: GetClientRect
2. Destroy the old control: DestroyWindow
3. Create the new control with stored position: CreateWindowEx
However, a far better solution may be to use an edit control only and set the read-only style as required. This can be done with the EM_SETREADONLY message.
Another option is to hide one control and show other control. This is helpful if the controls are very different types or you want to change multiple times.
Set the controls WS_VISIBLE style in the resource editor or when creating the control. As required use ShowWindow() (SW_SHOW==visible and SW_HIDE==invisible).
In this case I think the read only / disabled edit is the best idea.
"Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
Friedrich Nietzsche
"I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
George Best
"If you are going through hell....keep going."
Winston Churchill
Thanks for your replies:
This is what I have...my only problem is rctxt.left because isn't in the right place, anyideas?Code:HWND hIcon = FindWindowEx(HWND(wParam), 0, "STATIC", 0); HWND hText = FindWindowEx(HWND(wParam), hIcon, "STATIC", 0); GetWindowRect(hText, &rctxt); OffsetRect(&rctxt, -rctxt.left, -rctxt.top); DestroyWindow(hText); HWND hLink = CreateWindowEx(0, "SysLink", "Hola, mi <A HREF=\"http://www.joelito.net/\">sitio</a>, bye.", WS_CHILD|WS_VISIBLE|WS_TABSTOP, 0, 0, rctxt.right-rctxt.left, rctxt.bottom-rctxt.top, HWND(wParam), HMENU(1006), GetModuleHandle(0), 0); SetWindowPos(hLink, 0, rctxt.left, rctxt.bottom, 0, 0, SWP_NOSIZE|SWP_NOZORDER);
* Debian 6.0.1 on Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM.
* lighttpd, php5, perl, eruby, python.
* geany, XHTML & CSS & JavaScript, C, C++.
* GTK+ C & perl-gtk2