Add a horizontal line (separator) in form
Add a horizontal line (separator) in form
I need a way to add horizontal lines to forms. I would like to do this with Win32 API calls, if possible.
Thanks in advance!!
Thanks in advance!!
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
It's not API, but of course you're working with PB, right?
Code: Select all
OpenWindow(0,0,0,640,480,"",#PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_SizeGadget)
CreateGadgetList(WindowID(0))
CreateImage(0,1280,2)
StartDrawing(ImageOutput(0))
Box(0,0,1280,1,$A0A0A0)
Box(0,1,1280,1,#White)
StopDrawing()
ImageGadget(0,0,240,640,2,ImageID(0))
DisableGadget(0,1)
Repeat
ev = WaitWindowEvent()
Select ev
Case #PB_Event_SizeWindow
ResizeGadget(0,0,WindowHeight(0)/2,WindowWidth(0),2)
EndSelect
Until ev = #PB_Event_CloseWindow
Last edited by netmaestro on Thu May 25, 2006 7:39 pm, edited 1 time in total.
BERESHEIT
I think neomember wants to have a horizontal bar like <HR> in HTML pages, right? In this case, my code is better and maybe faster (Creating a image with 1280 width takes a lot memory)
Code: Select all
If OpenWindow(0, 0, 0, 640, 480, "Horizontal Bar", #PB_Window_SystemMenu|#PB_Window_SizeGadget|1)
If CreateGadgetList(WindowID(0))
ContainerGadget(0, 0, 0, 0, 0, #PB_Container_Single)
CloseGadgetList()
EndIf
Repeat
Event=WaitWindowEvent()
If Event=#PB_Event_SizeWindow
ResizeGadget(0, 0, WindowHeight(0)/2, WindowWidth(0), 2)
EndIf
Until Event=#PB_Event_CloseWindow
EndIf
-
- Addict
- Posts: 1073
- Joined: Fri Apr 25, 2003 11:13 pm
- Location: Netherlands
- Contact:
@Edwin: you don't need all those constants, I made a Macro, which should simplify things a bit:
Code: Select all
Macro HorizontalBarGadget(Window, x, y, Width)
CreateWindowEx_(0, "Static", "", #WS_CHILD|#WS_VISIBLE|#SS_ETCHEDHORZ, x, y, Width, 2, WindowID(Window), 0, GetModuleHandle_(0), 0)
EndMacro
-
- Addict
- Posts: 1073
- Joined: Fri Apr 25, 2003 11:13 pm
- Location: Netherlands
- Contact:
Thanks, works fine.
PBDev users create module and dump the macro in that.
After lines: (In Main module)
; Obtain window id, we use it during the loop.
MainID = PBD_GetWindowId( hWndMain )
HorizontalBarGadget(MainID, 20, 100, 100)
Or better, forget the macro and use a custom control (toolsbox) and set:
Classname property to: STATIC
WindowStyle: SS_ETCHEDHORZ
Appearance to: none
PBDev users create module and dump the macro in that.
After lines: (In Main module)
; Obtain window id, we use it during the loop.
MainID = PBD_GetWindowId( hWndMain )
HorizontalBarGadget(MainID, 20, 100, 100)
Or better, forget the macro and use a custom control (toolsbox) and set:
Classname property to: STATIC
WindowStyle: SS_ETCHEDHORZ
Appearance to: none
Edwin this works like a charm
Having the Appearance switch set to it's default doesn't
matter, the WindowStyle criteria seems to dominate.
--blueb

Having the Appearance switch set to it's default doesn't
matter, the WindowStyle criteria seems to dominate.
--blueb
- It was too lonely at the top.
System : PB 6.21(x64) and Win 11 Pro (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem
System : PB 6.21(x64) and Win 11 Pro (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem
-
- Addict
- Posts: 1073
- Joined: Fri Apr 25, 2003 11:13 pm
- Location: Netherlands
- Contact:
All good solutions... thanks everybody!
I'm trying to learn programming through multiple languages. I like the API calls better because you can use it in almost every languages. It gives me a better understanding of how Windows works. I think that creating your own GUI using pure Win32 API in C/C++ is a good challenge for a beginner.
I'm pretty impressed by how easily you can create GUIs in Purebasic and without affecting the executable size also.
Do PB has it's own GUI library? Looks like an API wrapper to me.
I would like to write myself a wrapper for C/C++. It looks simple but it supposed to be a tedious task.
Maybe someday!!!
I'm using D-LIB also... i think it's pretty impressive!! Too bad the development stopped
It doesn't need much more.
BCX is good too... for learning!
Thanks again!
I'm trying to learn programming through multiple languages. I like the API calls better because you can use it in almost every languages. It gives me a better understanding of how Windows works. I think that creating your own GUI using pure Win32 API in C/C++ is a good challenge for a beginner.
I'm pretty impressed by how easily you can create GUIs in Purebasic and without affecting the executable size also.
Do PB has it's own GUI library? Looks like an API wrapper to me.
I would like to write myself a wrapper for C/C++. It looks simple but it supposed to be a tedious task.
Maybe someday!!!
I'm using D-LIB also... i think it's pretty impressive!! Too bad the development stopped

It doesn't need much more.
BCX is good too... for learning!
Thanks again!
Learning the Win32 API whilst you are a beginner isn't a very good idea. You should first learn the basics of programming like structures, interfaces, prototypes and so on. And to learn programming for multiple languages isn't also a very good idea. Perhaps an expert would do stuff like that, but you said yourself that you are a beginner.
About the PB GUI (Gadgets) library, It's not an API wrapper, Fred has made his custom gadgets too, and yes, for example an EditorGadget is RichEdit20A, but the PB commands are mostly cross-platform, so mostly the same GUI is compatible with Linux and MacOS X too; if you'd use API, you could use your GUI only in window$
And to create a wrapper for c/c++ is really a hard task.
And BTW: compare the executable sizes if you use API commands instead of the PB ones in creating a simple GUI. You'll see that the API one is more than 45% bigger in size. Also, most of the PB's functions are cross-platform, so don't forget that.
About the PB GUI (Gadgets) library, It's not an API wrapper, Fred has made his custom gadgets too, and yes, for example an EditorGadget is RichEdit20A, but the PB commands are mostly cross-platform, so mostly the same GUI is compatible with Linux and MacOS X too; if you'd use API, you could use your GUI only in window$
And to create a wrapper for c/c++ is really a hard task.
And BTW: compare the executable sizes if you use API commands instead of the PB ones in creating a simple GUI. You'll see that the API one is more than 45% bigger in size. Also, most of the PB's functions are cross-platform, so don't forget that.

There's also my code here...
http://www.purebasic.fr/english/viewtopic.php?t=18332
...that'll give you some different options on drawing on a window.
http://www.purebasic.fr/english/viewtopic.php?t=18332
...that'll give you some different options on drawing on a window.
- netmaestro
- PureBasic Bullfrog
- Posts: 8451
- Joined: Wed Jul 06, 2005 5:42 am
- Location: Fort Nelson, BC, Canada
...isn't very useful as a macro in its present form. In order to make it a usable tool it needs to be a procedure that returns the handle of the created window, else you can't do anything with it. Here's a procedure version that allows for resizing the window, etc:but your code is very big, whilst my macro..
Code: Select all
Procedure HorizontalBarGadget(Window, x, y, Width)
hwnd = CreateWindowEx_(0, "Static", "", #WS_CHILD|#WS_VISIBLE|#SS_ETCHEDHORZ, x, y, Width, 2, WindowID(Window), 0, GetModuleHandle_(0), 0)
ProcedureReturn hwnd
EndProcedure
OpenWindow(0,0,0,640,480,"",#PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_SizeGadget)
horizline = horizontalbargadget(0,0,240,640)
Repeat
ev = WaitWindowEvent()
Select ev
Case #PB_Event_SizeWindow
SetWindowPos_(horizline,0,0,WindowHeight(0)/2,WindowWidth(0)+1,2,#SWP_NOZORDER)
EndSelect
Until ev = #PB_Event_CloseWindow
BERESHEIT
My macro works as expected, as it's replaced with the CreateWindowEx_ line which returns the hWnd.netmaestro wrote:...isn't very useful as a macro in its present form. In order to make it a usable tool it needs to be a procedure that returns the handle of the created window, else you can't do anything with it. Here's a procedure version that allows for resizing the window, etc:but your code is very big, whilst my macro..Code: Select all
Procedure HorizontalBarGadget(Window, x, y, Width) hwnd = CreateWindowEx_(0, "Static", "", #WS_CHILD|#WS_VISIBLE|#SS_ETCHEDHORZ, x, y, Width, 2, WindowID(Window), 0, GetModuleHandle_(0), 0) ProcedureReturn hwnd EndProcedure OpenWindow(0,0,0,640,480,"",#PB_Window_SystemMenu|#PB_Window_ScreenCentered|#PB_Window_SizeGadget) horizline = horizontalbargadget(0,0,240,640) Repeat ev = WaitWindowEvent() Select ev Case #PB_Event_SizeWindow SetWindowPos_(horizline,0,0,WindowHeight(0)/2,WindowWidth(0)+1,2,#SWP_NOZORDER) EndSelect Until ev = #PB_Event_CloseWindow
Last edited by josku_x on Fri May 26, 2006 10:53 pm, edited 1 time in total.
you can also use CreateGadget.pbi
http://www.purebasic.fr/english/viewtopic.php?t=21412
http://www.purebasic.fr/english/viewtopic.php?t=21412
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
