Mark_FreeSoftware
asked on
Command button Style on runtime
hello experts,
how can i change the style from the default command button at runtime?
whenever i try the Command1.style = 1 at Form_load, i get the error that this is not possible at runtime.
can this been done using api's or somthing like that?
mark
ASKER
i have a code snippet that changes the buttons to C style buttons (no ugly black border)
but that will only work when the style is graphical
What is wrong with setting them at design time?
ASKER
i want to add that function to a few existing projects, so it is very much work to find all command buttons
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
GetWindowLong and SetWindowLong
can you pls give an example of that,
since i have already code that walks trough all command buttons at startup, i just can add that code to it, so that i only have to add that code at the startup of the form
Like I said, I have never done such a thing, I do not know the codes for get and setwindowlong to change a picturebox style.
However, the code I have posted is a complete project which when compiled will allow you to drag frm files to it and it will
change all of the command buttons to graphical at design-time without you having to find all the buttons and set them manually.
Your choices are pretty much that or to wait for another expert who may be more familiar with Get and Setwindowlong on
picture boxes. Perhaps a pointer question asking for help with Get/Setwindowlong on pictureboxes?
However, the code I have posted is a complete project which when compiled will allow you to drag frm files to it and it will
change all of the command buttons to graphical at design-time without you having to find all the buttons and set them manually.
Your choices are pretty much that or to wait for another expert who may be more familiar with Get and Setwindowlong on
picture boxes. Perhaps a pointer question asking for help with Get/Setwindowlong on pictureboxes?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
iHadi, I did something very similar to that, however you are facing the same problem I had. Your button stops drawing correctly.
And in turn is not a proper graphical styled button.
And in turn is not a proper graphical styled button.
ASKER
i don't think the only difference between the 2 styles is the gwl_style, cause i copied the style from a graphical button to a normal one, and that didnt work either....
but i have no idea what else is different.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
when the button loses focus, the border does disappear
Mark, I really think you will be best off just setting your button at design-time.
ASKER
too bad.....
if i want an addin for vb (6.0) to do that, should i open a new question or can i ask it here?
ASKER
oh well, nvm i just ask a new question and split points because you 3 took the time to listen to me and to try it.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
GPrentice00, I tried that same thing, I found the difference to be 8203. I found this by doing a xor
of the two. I then tried using that, however to no success. I see the real problem was not my method,
but the picture not being set to nothing.
Mark_FreeSoftware:
Just so you know rather than &HB OR &H2000 you can simply do:
SetWindowLong CMDBTN.hwnd, GWL_STYLE, winLong Or 8203 '//Note the 8203
of the two. I then tried using that, however to no success. I see the real problem was not my method,
but the picture not being set to nothing.
Mark_FreeSoftware:
Just so you know rather than &HB OR &H2000 you can simply do:
SetWindowLong CMDBTN.hwnd, GWL_STYLE, winLong Or 8203 '//Note the 8203
make changes anyway.