Hello José... me again...
And with DDT again...
If i create a dialog non overlapped (not redim) and a statusbar : the statusbar has always the resize handle draw.
Second problem :
If i create a statusbar (first) and a menu (second), the statusbar is not visible.
' // Create a new dialog using dialog units
DIM hDlg AS HWND = DialogNew(0, "Bio", , , 200, 200, WS_CAPTION OR WS_SYSMENU OR DS_3DLOOK OR WS_MINIMIZEBOX or DS_CENTER)
' // Add a button to the dialog
ControlAddButton, hDlg, IDC_OK, "&Ok", 105, 40, 50, 12, BS_DEFPUSHBUTTON
'
CONTROLADDSTATUSBAR, hDlg, SBAR, "", 75, 105, 45, 15
STATUSBARSETPARTS hdlg,sbar,"120,-1"
'
dim hmenu as hmenu=MENUNEWBAR
dim hpopup1 as hmenu = MENUNEWPOPUP
MENUADDPOPUP hMenu, "&Options", hPopup1, MF_ENABLED
MENUADDSTRING hpopup1, "Exit",id_quit,MF_ENABLED
menuattach hmenu,hdlg
'
'CONTROLADDSTATUSBAR, hDlg, SBAR, "", 75, 105, 45, 15
'STATUSBARSETPARTS hdlg,sbar,"120,-1"
Sorry for use DDT, but its very easy to port Powerbasic code with it...
The size grip has nothing to do with overlapped or not overlapped dialogs. ControlAddStatusBar sets it by default. If you don't want it then specify the styles that yu want.
ControlAddStatusBar, hDlg, SBAR, "", 75, 105, 45, 15, WS_VISIBLE OR WS_CLIPCHILDREN OR WS_CLIPSIBLINGS OR CCS_BOTTOM
Thanx José. Work as expected.
Hello José,
Maybe a problem with statusbar (with DDT)...
With this code the statusbar is not visible :
'#TEMPLATE DDT Dialog with a button
#define UNICODE
#define _WIN32_WINNT &h0602
#include once "AfxNova/DDT.inc"
USING AfxNova
DECLARE FUNCTION wWinMain (BYVAL hInstance AS HINSTANCE, _
BYVAL hPrevInstance AS HINSTANCE, _
BYVAL pwszCmdLine AS WSTRING PTR, _
BYVAL nCmdShow AS LONG) AS LONG
END wWinMain(GetModuleHandleW(NULL), NULL, wCommand(), SW_NORMAL)
DECLARE FUNCTION DlgProc (BYVAL hDlg AS HWND, BYVAL uMsg AS DWORD, BYVAL wParam AS DWORD, BYVAL lParam AS LPARAM) AS INT_PTR
CONST IDC_OK = 1001
const sbar = 1002
const id_quit=1003
' ========================================================================================
' Main
' ========================================================================================
FUNCTION wWinMain (BYVAL hInstance AS HINSTANCE, _
BYVAL hPrevInstance AS HINSTANCE, _
BYVAL pwszCmdLine AS WSTRING PTR, _
BYVAL nCmdShow AS LONG) AS LONG
' // Set process DPI aware
SetProcessDpiAwareness(PROCESS_SYSTEM_DPI_AWARE)
' // Enable visual styles without including a manifest file
AfxEnableVisualStyles
' // Create a new dialog using dialog units
'DIM hDlg AS HWND = DialogNew(0, "DDT Dialog with a button", 50, 50, 175, 65, WS_OVERLAPPEDWINDOW OR DS_CENTER)
DIM hDlg AS HWND = DialogNew(0, "DDT Dialog statusbar not visible... :(", , , 175, 200, WS_CAPTION OR WS_SYSMENU or DS_CENTER)
'
CONTROLADDSTATUSBAR, hDlg, SBAR, "", 75, 105, 45, 15, WS_VISIBLE OR WS_CLIPCHILDREN OR WS_CLIPSIBLINGS OR CCS_BOTTOM
STATUSBARSETPARTS hdlg,sbar,"120,-1"
'
dim hmenu as hmenu=MENUNEWBAR
dim hpopup1 as hmenu = MENUNEWPOPUP
MENUADDPOPUP hMenu, "&Options", hPopup1, MF_ENABLED
MENUADDSTRING hpopup1, "Exit",id_quit,MF_ENABLED
menuattach hmenu,hdlg
'
'CONTROLADDSTATUSBAR, hDlg, SBAR, "", 75, 105, 45, 15, WS_VISIBLE OR WS_CLIPCHILDREN OR WS_CLIPSIBLINGS OR CCS_BOTTOM
'STATUSBARSETPARTS hdlg,sbar,"120,-1"
' // Add a button to the dialog
ControlAddButton, hDlg, IDC_OK, "&Ok", 105, 40, 50, 12, BS_DEFPUSHBUTTON
' // Anchor the button to the bottom and the right side of the dialog
ControlAnchor(hDlg, IDC_OK, AFX_ANCHOR_BOTTOM_RIGHT)
' // Display and activate the dialog as modal
DialogShowModal(hDlg, @DlgProc)
RETURN DialogEndResult(hDlg)
END FUNCTION
' ========================================================================================
' ========================================================================================
' Dialog callback procedure
' ========================================================================================
FUNCTION DlgProc (BYVAL hDlg AS HWND, BYVAL uMsg AS DWORD, BYVAL wParam AS DWORD, BYVAL lParam AS LPARAM) AS INT_PTR
SELECT CASE uMsg
CASE WM_INITDIALOG
RETURN TRUE
CASE WM_COMMAND
SELECT CASE CBCTL(wParam, lParam)
CASE IDCANCEL
' // If ESC key pressed, close the application by sending an WM_CLOSE message
IF CBCTLMSG(wParam, lParam) = BN_CLICKED THEN
SendMessageW hDlg, WM_CLOSE, 0, 0
END IF
CASE IDC_OK
MsgBox("OK button pressed", MB_ICONEXCLAMATION OR MB_TASKMODAL, "Message")
END SELECT
CASE WM_CLOSE
' // End the application
DialogEnd(hDlg)
END SELECT
RETURN FALSE
END FUNCTION
and with this code : all is OK :
'#TEMPLATE DDT Dialog with a button
#define UNICODE
#define _WIN32_WINNT &h0602
#include once "AfxNova/DDT.inc"
USING AfxNova
DECLARE FUNCTION wWinMain (BYVAL hInstance AS HINSTANCE, _
BYVAL hPrevInstance AS HINSTANCE, _
BYVAL pwszCmdLine AS WSTRING PTR, _
BYVAL nCmdShow AS LONG) AS LONG
END wWinMain(GetModuleHandleW(NULL), NULL, wCommand(), SW_NORMAL)
DECLARE FUNCTION DlgProc (BYVAL hDlg AS HWND, BYVAL uMsg AS DWORD, BYVAL wParam AS DWORD, BYVAL lParam AS LPARAM) AS INT_PTR
CONST IDC_OK = 1001
const sbar = 1002
const id_quit=1003
' ========================================================================================
' Main
' ========================================================================================
FUNCTION wWinMain (BYVAL hInstance AS HINSTANCE, _
BYVAL hPrevInstance AS HINSTANCE, _
BYVAL pwszCmdLine AS WSTRING PTR, _
BYVAL nCmdShow AS LONG) AS LONG
' // Set process DPI aware
SetProcessDpiAwareness(PROCESS_SYSTEM_DPI_AWARE)
' // Enable visual styles without including a manifest file
AfxEnableVisualStyles
' // Create a new dialog using dialog units
'DIM hDlg AS HWND = DialogNew(0, "DDT Dialog with a button", 50, 50, 175, 65, WS_OVERLAPPEDWINDOW OR DS_CENTER)
DIM hDlg AS HWND = DialogNew(0, "DDT Dialog statusbar visible... ;)", , , 175, 200, WS_CAPTION OR WS_SYSMENU or DS_CENTER)
'
' CONTROLADDSTATUSBAR, hDlg, SBAR, "", 75, 105, 45, 15, WS_VISIBLE OR WS_CLIPCHILDREN OR WS_CLIPSIBLINGS OR CCS_BOTTOM
'STATUSBARSETPARTS hdlg,sbar,"120,-1"
'
dim hmenu as hmenu=MENUNEWBAR
dim hpopup1 as hmenu = MENUNEWPOPUP
MENUADDPOPUP hMenu, "&Options", hPopup1, MF_ENABLED
MENUADDSTRING hpopup1, "Exit",id_quit,MF_ENABLED
menuattach hmenu,hdlg
'
CONTROLADDSTATUSBAR, hDlg, SBAR, "", 75, 105, 45, 15, WS_VISIBLE OR WS_CLIPCHILDREN OR WS_CLIPSIBLINGS OR CCS_BOTTOM
STATUSBARSETPARTS hdlg,sbar,"120,-1"
' // Add a button to the dialog
ControlAddButton, hDlg, IDC_OK, "&Ok", 105, 40, 50, 12, BS_DEFPUSHBUTTON
' // Anchor the button to the bottom and the right side of the dialog
ControlAnchor(hDlg, IDC_OK, AFX_ANCHOR_BOTTOM_RIGHT)
' // Display and activate the dialog as modal
DialogShowModal(hDlg, @DlgProc)
RETURN DialogEndResult(hDlg)
END FUNCTION
' ========================================================================================
' ========================================================================================
' Dialog callback procedure
' ========================================================================================
FUNCTION DlgProc (BYVAL hDlg AS HWND, BYVAL uMsg AS DWORD, BYVAL wParam AS DWORD, BYVAL lParam AS LPARAM) AS INT_PTR
SELECT CASE uMsg
CASE WM_INITDIALOG
RETURN TRUE
CASE WM_COMMAND
SELECT CASE CBCTL(wParam, lParam)
CASE IDCANCEL
' // If ESC key pressed, close the application by sending an WM_CLOSE message
IF CBCTLMSG(wParam, lParam) = BN_CLICKED THEN
SendMessageW hDlg, WM_CLOSE, 0, 0
END IF
CASE IDC_OK
MsgBox("OK button pressed", MB_ICONEXCLAMATION OR MB_TASKMODAL, "Message")
END SELECT
CASE WM_CLOSE
' // End the application
DialogEnd(hDlg)
END SELECT
RETURN FALSE
END FUNCTION
If statusbar is defined before menu : not visible. Normal ?
It is shown, but the heigth size is tiny. Probably one of these pesky caprices of the dialog engine. Add ControlAnchor, that will position the Status bar where it should. Please notice that the values of x, y, width, height aren't used for anything.
CONTROLADDSTATUSBAR, hDlg, SBAR, "", 0, 0, 0, 0, WS_VISIBLE OR WS_CLIPCHILDREN OR WS_CLIPSIBLINGS OR CCS_BOTTOM
STATUSBARSETPARTS hdlg,sbar,"120,-1"
ControlAnchor(hDlg, SBAR, AFX_ANCHOR_BOTTOM_WIDTH)