Hello All
so far i have been only using DDT dialogs style, so this is my first attempt of using SDK style
which is faciliated by O2 's WinUtil.inc
this is a simple SDK style screen with a data entry textbox and 2 buttons
as you would bet, O2 's has some powerful maestros behind it, namely Charles Pegge and Roland
and that explains why O2 is so much superior than other languages
' SDK_screen.O2bas
' Updated Dec 30 2018
$ filename "SDK_screen.exe"
uses rtl64
'% review
uses O2common
uses winUtil
#lookahead
' Control Identifiers
' Form1
% IDD_FORM1 = 100
% IDC_FORM1_EDIT1 = 101
% IDI_LOGO 400
sys ghInstance ' handle of the application instance
'=================================
'Set the Icon to the Main Window
SUB SetMainIcon( sys hmWnd )
'Set Icon to Main Window
sys hInstance = GetModuleHandle(NULL)
sys hIcon = LoadIcon(hInstance, IDI_Logo)
SendMessage(hmWnd , WM_SETICON, ICON_BIG, hIcon)
End Sub
' ===============================================
' PURPOSE: Processes messages for the Form1 window.
FUNCTION WndProc _
( _
BYVAL hWnd AS sys, _ ' window handle
BYVAL uMsg AS uint , _ ' type of message
BYVAL wParam AS sys, _ ' first message parameter
BYVAL lParam AS sys _ ' second message parameter
) AS sys Callback
LOCAL hWndChild AS sys ' handle of child window
LOCAL hFont AS sys ' handle of font used by form
SELECT CASE uMsg
CASE WM_CREATE
'Set Icon to Main Window
SetMainIcon hwnd
' Create and save the font used by the form
hFont = GetStockObject( DEFAULT_GUI_FONT)
SendMessage hWnd, WM_SETFONT, hFont, FALSE
' Place the title for the Main Window
SetWindowText (hwnd, "Please enter your user ID" )
' Create the Edit1 edit control
hWndChild = CreateWindowEx( WS_EX_CLIENTEDGE, _ ' extended styles
"Edit", _ ' class name
"", _ ' caption
WS_CHILD OR WS_VISIBLE OR WS_TABSTOP OR _ ' window styles
ES_LEFT OR ES_AUTOHSCROLL, _ ' class styles
10, 55, 150, 25,
hWnd, IDC_FORM1_EDIT1, _ ' handle of parent, control ID
ghInstance, BYVAL NULL) ' handle of instance, creation parameters
SendMessage hWndChild, WM_SETFONT, hFont, TRUE
' Create the OK text button
hWndChild = CreateWindowEx(0, _ ' extended styles
"Button", _ ' class name
"OK", _ ' caption
WS_CHILD OR WS_VISIBLE OR WS_TABSTOP OR _ ' window styles
BS_DEFPUSHBUTTON OR BS_CENTER OR BS_VCENTER, _ ' class styles
20, 90, 45, 20,
hWnd, IDOK, _ ' handle of parent, control ID
ghInstance, BYVAL NULL) ' handle of instance, creation parameters
SendMessage hWndChild, WM_SETFONT, hFont, TRUE
' Create the Cancel button
hWndChild = CreateWindowEx(0, _ ' extended styles
"Button", _ ' class name
"Cancel", _ ' caption
WS_CHILD OR WS_VISIBLE OR WS_TABSTOP OR _ ' window styles
BS_PUSHBUTTON OR BS_CENTER OR BS_VCENTER, _ ' class styles
90, 90, 75, 20,
hWnd, IDCANCEL, _ ' handle of parent, control ID
ghInstance, BYVAL NULL) ' handle of instance, creation parameters
SendMessage hWndChild, WM_SETFONT, hFont, TRUE
FUNCTION = FALSE
EXIT FUNCTION
CASE WM_ERASEBKGND
' added to display background color for the main window
' for a Mint_Cream background
MainWindBGColor = BGc_Mint_Cream
hBGDC = wParam
' Pass the DC of the region to be repaint
DrawGradient hBGDC
FUNCTION = 1
EXIT FUNCTION
CASE WM_COMMAND
SELECT CASE LOword( wParam)
CASE IDOK
IF HIword( wParam) = BN_CLICKED THEN
IF ISTRUE Form1_OK_Clicked(hWnd, lParam) THEN
FUNCTION = FALSE
EXIT FUNCTION
END IF
END IF
CASE IDCANCEL
IF HIword( wParam) = BN_CLICKED THEN
IF ISTRUE Form1_Cancel_Clicked(hWnd, lParam) THEN
FUNCTION = FALSE
EXIT FUNCTION
END IF
END IF
END SELECT
CASE WM_SETFOCUS
' Set the keyboard focus to the first control that is
' visible, not disabled, and has the WS_TABSTOP style
SetFocus GetNextDlgTabItem(hWnd, NULL, FALSE)
CASE WM_CLOSE
CASE WM_DESTROY
DeleteObject RemoveProp(hWnd, "FONT")
PostQuitMessage 0
FUNCTION = FALSE
EXIT FUNCTION
CASE WM_GETFONT
' Return the handle of the font used by the form
FUNCTION = GetProp(hWnd, "FONT")
EXIT FUNCTION
CASE WM_SETFONT
' Get the current font used by the form
hFont = GetProp(hWnd, "FONT")
' Set the new font
SetProp hWnd, "FONT", wParam
IF ISTRUE lParam THEN
InvalidateRect hWnd, BYVAL NULL, TRUE
UpdateWindow hWnd
END IF
FUNCTION = hFont
EXIT FUNCTION
END SELECT
FUNCTION = DefWindowProc(hWnd, uMsg, wParam, lParam)
END FUNCTION
'=====================================
' PROCEDURE: Form1_OK_Clicked
' PURPOSE: OK button notification handler.
' RETURN: TRUE if message was processed, FALSE if it was not.
FUNCTION Form1_OK_Clicked _
( _
BYVAL hWndParent AS sys, _ ' handle of parent window
BYVAL hWndCtrl AS sys _ ' handle of control
) AS LONG
string textNam=nuls 20
GetWindowText(GetDlgItem(hWndParent, IDC_FORM1_EDIT1), textNam, 20)
Mbox " Hello " +textNam, 0
SendMessage hWndParent, WM_CLOSE, 0, 0
END FUNCTION
'======================================
' PROCEDURE: Form1_Cancel_Clicked
' PURPOSE: Cancel button notification handler.
' RETURN: TRUE if message was processed, FALSE if it was not.
FUNCTION Form1_Cancel_Clicked _
( _
BYVAL hWndParent AS sys, _ ' handle of parent window
BYVAL hWndCtrl AS sys _ ' handle of control
) AS LONG
SendMessage hWndParent, WM_CLOSE, 0, 0
END FUNCTION
'-------------------------
' Program start
MainWindow 420,260,WS_OVERLAPPEDWINDOW