ObjReader Community

Discussion => Post Your Questions & Comments Here => Topic started by: Frederick Harris on December 26, 2021, 05:27:10 pm

Title: PureBasic
Post by: Frederick Harris on December 26, 2021, 05:27:10 pm
I keep wondering about PureBasic.  It seems to have a lot of advantages.  I was actually thinking of buying it last summer for a try, but when I got to doing some research on it I discovered a number of things about it I didn't care for at all.  For example, one can write code like in old DOS GWBASIC or QuickBasic that isn't contained in procedures such as main(), WinMain(), PBMain(), etc.  Further, instead of using the '.' character to seperate struct/UDT members it uses the '\' character.  All that was just too strange to me.  There's a good writeup on it here at CodeProject....


In that article he provides an SDK GUI example as follows...

Code: [Select]
; If you want to use in GUI not only latin characters, compile it in Unicode!
; Warning: exe size - it's very, very small!

Declare.l WndProc(hWnd, Msg, wParam, lParam) ; declare Window events callback

; Global vars
WindowClass.s = "WndClass1"

; Initialize Window Class
wc\cbSize = SizeOf(WNDCLASSEX)
wc\hbrBackground = #COLOR_WINDOW
wc\hCursor = LoadCursor_(0, #IDC_ARROW)
wc\lpfnWndProc = @WndProc()
wc\lpszClassName = @WindowClass

; register Window Class
If RegisterClassEx_(@wc) = 0
  MessageBox_(hWnd, "Can't register main window class.", "", #MB_ICONERROR)

; create window
hWnd = CreateWindowEx_(0, WindowClass, "Lorem ipsum", #WS_SYSMENU, 10, 50, 400, 200, 0, 0, 0, 0)
If hWnd = 0
  MessageBox_(hWnd, "Can't create main window.", "", #MB_ICONERROR)

; create button and set it's font
hButton1 = CreateWindowEx_(0, "Button", "Button 1", #WS_CHILD | #WS_VISIBLE, 10, 10, 100, 25, hWnd, 0, 0, 0)
SendMessage_(hButton1, #WM_SETFONT, GetStockObject_(#DEFAULT_GUI_FONT), 1)

; show window
ShowWindow_(hWnd, #SW_SHOWDEFAULT)

; messages handling loop
While GetMessage_(msg.MSG, #Null, 0, 0 )

; window events callback
Procedure.l WndProc(hWnd, Msg, wParam, lParam)
  Shared hButton1
  Select Msg
    Case #WM_COMMAND
      If hButton1 = lParam
        MessageBox_(hWnd, "Button 1 clicked!", "", #MB_OK)
    Case #WM_CLOSE
    Case #WM_DESTROY
      PostQuitMessage_(0) : Result  = 0
      Result  = DefWindowProc_(hWnd, Msg, wParam, lParam)
  ProcedureReturn Result

I'd be interested in anyone's comments on it.  Too bad PowerBASIC is left out of the 64 bit world.

Title: Re: PureBasic
Post by: Patrice Terrier on December 26, 2021, 10:46:39 pm
Good SDK coder avoid to use exotic Gadget ;)