WORKING Group Box?
BlitzPlus Forums/BlitzPlus Programming/WORKING Group Box?
| ||
Does anyone have code for a working group box? Ive seen a couple of others but non of them work properly, mostly due to them not getting re-painted? |
| ||
Anyone? |
| ||
I included group boxes in my form editor, but it's shareware... link in my sig, though! |
| ||
Could you post the group box code? I pretty much broke at the moment! ive got this but it dosent seem to redraw, does anyone know hos to get it to work? Function CreateGroupBox(name$, x, y, w, h, p) Local groupbox, hwnd groupbox = CreateButton(name, x, y, w, h, p) hwnd = QueryObject(groupbox, 1) api_SetWindowLong(hwnd, GWL_STYLE, api_GetWindowLong(hwnd, GWL_STYLE)+7) Return groupbox End Function |
| ||
How about this. Some flicker when you resize the window. You can't parent anything to it either. I don't know if this is even possible since bizarrely, in Windows a groupbox is actually a button.; .lib "User32.dll" ; SendMessage%(hWnd%,Msg%,wParam%,lParam%):"SendMessageA" Const BM_SETSTYLE = 244 Const BS_GROUPBOX = 7 Global win=CreateWindow ("Win",10,10,600,600,main,15) groupbox=CreateGroupBox("Woo a Groupbox",10,10,300,300,win) SetGadgetLayout groupbox,1,0,1,0 While WaitEvent(10)<>$803 Wend End Function CreateGroupBox(name$, x, y, w, h, p) groupbox = CreateButton(name, x, y, w, h, p,2) hwnd = QueryObject(groupbox, 1) SendMessage (hwnd, BM_SETSTYLE, BS_GROUPBOX ,1) pan=CreatePanel (x,y,w,h,p) SetGadgetLayout pan,1,0,1,0 Return groupbox End Function |
| ||
Wiebo - any updates planned? It's been a LOOOOONG while since there was any activity on the forum so I was just wondering.. |
| ||
its ok i made my own, ive posted it in the code archives if your intrested! |
| ||
I fixed your code so that the groupbox will be treated as a single gadget. The only caveat is you have to create any gadgets inside the group box before you make the groupbox, or you have to get the background panel handle and parent the gadget to that.Const BM_SETSTYLE=244 Const BS_GROUPBOX=7 win=CreateWindow ("Win",10,10,400,400,main,15) button1=CreateButton("test",40,40,80,30,win) SetGadgetLayout button1,1,0,1,0 groupbox=CreateGroupBox("Woo a Groupbox",10,10,300,300,win) SetGadgetLayout groupbox,1,1,1,1 button2=CreateButton("test2",200,40,80,30,win) SetGadgetLayout button2,1,0,1,0 While WaitEvent(10)<>$803 Wend End Function CreateGroupBox(name$,x,y,w,h,parent) mainpanel=CreatePanel(x,y,w,h,parent) groupbox=CreateButton(name,0,0,w,h,mainpanel) SetGadgetLayout groupbox,1,1,1,1 SendMessage QueryObject(groupbox,1),BM_SETSTYLE,BS_GROUPBOX,1 backgroundpanel=CreatePanel(0,0,ClientWidth(mainpanel),ClientHeight(mainpanel),mainpanel) SetGadgetLayout backgroundpanel,1,1,1,1 Return mainpanel End Function |
| ||
Here's another method. SetGadgetLayout commands won't work on this, but gadgets can be parented to the groupbox, the groupbox clips its children, and the flicker is gone:Const BM_SETSTYLE=244 Const BS_GROUPBOX=7 win=CreateWindow ("Win",10,10,400,400,main,15) groupbox=CreateGroupBox("Woo a Groupbox",10,10,300,300,win) button1=CreateButton("test",40,40,80,30,groupbox) SetGadgetLayout button1,1,0,1,0 button2=CreateButton("test2",200,40,80,30,groupbox) SetGadgetLayout button2,1,0,1,0 While WaitEvent(10)<>$803 Wend End Function CreateGroupBox(name$,x,y,w,h,parent) groupbox=CreateButton(name,x,y,w,h,parent) SetGadgetLayout groupbox,1,1,1,1 SendMessage QueryObject(groupbox,1),BM_SETSTYLE,BS_GROUPBOX,1 backgroundpanel=CreatePanel(x+2,y+2,w-4,h-4,parent) SetGadgetLayout backgroundpanel,1,1,1,1 Return backgroundpanel End Function |
| ||
And where does one find SendMessage? |
| ||
See the commented out lines in my code above? That's telling you to add the line SendMessage%(hWnd%,Msg%,wParam%,lParam%):"SendMessageA" to your user32 userlib. In short make a file called user32.decls add the commented lines. save it in your userlibs folder and restart B+. |
| ||
Something funky goin on. I pulled in user32.decls from the code library (placed in userlibs subdir) and replaced SendMessage with api_SendMessage. It runs but abends. I'm running B+ 1.40, XP SP2 on a 1.2GHz AMD and a Geforece 4800 video card (nothing special). |
| ||
Use this: SendMessage%(hwnd%,wMsg%,wParam%,lParam%) : "SendMessageA" NOT this: SendMessage%(hwnd%,wMsg%,wParam%,lParam*) : "SendMessageA" |
| ||
I really dont know why this feature isn't impleimented in the Panel gadget. A Panel is a naturual grouping gadget anyway and would only need an extra parameter to allow it to draw a border in the style of a group box and to allow a title at the top. Maybe this could be put in with the next update. Pretty please! CreatePanel( x,y,width,height,group,Title$[,style]) If style is set to 2 then draw the group border. |
| ||
Panels don't have a title$ parameter. But you could use SetGadgetText() instead. |
| ||
Panels don't have a title$ parameter. Doh! I know they don't! What I am suggesting is that they include it as a parameter. Please read my post carefully. |
| ||
But they already have a [style] parameter, so that would mess up existing code, plus it would not follow the parameter order convention. I would use CreateButton(title$,x,y,width,height,[style=3]) |
| ||
aero, Thanks for the SendMessage clarification. Can you explain: 1. what's the difference between lParam* and lParam% 2. why the user32.decls file used lParam* instead of lParam% (and why it hasn't sufficiently screwed everyone to date so that it was adjusted?) |
| ||
But they already have a [style] parameter Forget it, you don't get what I mean and I'm not going to explain any further. OK, you are correct. Congratulations. |