José,
I am using FireFly 3.51 with PBWin 10.03. I am actually doing my first project, so please forgive me if I am asking something too fundamental. But on FireFly's forum (http://www.planetsquires.com/protect/forum/index.php?topic=2765) it suggests coming to your forum for information on how XP Themed Buttons works. I tried searching your forum, but did not find anything related to that. Is it here?
Mil gracias y saludos,
Ron
dear ron, may be this example from josé roca (what I've found on my hd) end of august 2008 can help you for working. I add some equates in include file and do two changes as I've commented. all you can find in zip folder for testing.
xp themed button (sdk):
' ########################################################################################
' XPBUTTON Demo
' (C) 2008 José Roca
' ########################################################################################
' SED_PBWIN - Use the PBWIN compiler
#DIM ALL
#COMPILE EXE
#INCLUDE "COMMCTRL.INC"
#INCLUDE "XPBUTTON.INC"
#INCLUDE "windows.inc" ' "win32api.INC"
#RESOURCE "XPButtonDemo.PBR"
' ========================================================================================
' Control identifiers
' ========================================================================================
%IDC_STATIC = -1
%IDC_FORM1_STANDARDPUSHBUTTON = 101
%IDC_FORM1_ICONONLEFT = 102
%IDC_FORM1_ICONONRIGHT = 103
%IDC_FORM1_NOICON = 104
%IDC_FORM1_NOTEXT = 105
%IDC_FORM1_TOGGLEBUTTON = 106
%IDC_FORM1_ENABLETHEMING = 107
%IDC_FORM1_XPBUTTON = 108
' ========================================================================================
' Global variables
' ========================================================================================
GLOBAL ghInstance AS DWORD ' handle of the application instance
' ========================================================================================
' PROCEDURE: phnxCenterWindow
' PURPOSE: Centers one window over another. It also ensures that the
' placement is within the 'working area', meaning that it is
' both within the display limits of the screen, -and- not
' obscured by the tray or other frameing elements of the
' desktop.
' ========================================================================================
FUNCTION phnxCenterWindow ( _
BYVAL hWndChild AS DWORD, _ ' handle of window to center
BYVAL hWndParent AS DWORD _ ' handle of reference window or NULL if window is the screen
) AS LONG
LOCAL trcChild AS RECT ' Child window dimensions
LOCAL trcParent AS RECT ' Parent window dimensions
LOCAL trcWorkArea AS RECT ' Work area dimensions
LOCAL tpt AS POINTAPI ' x and y coordinate of centered window
LOCAL cxChild AS LONG ' Width of child window
LOCAL cyChild AS LONG ' Height of child window
LOCAL cxParent AS LONG ' Width of parent window
LOCAL cyParent AS LONG ' Height of parent window
LOCAL fResult AS LONG ' Return flag for SystemParametersInfo()
' Get the Height and Width of the child window
GetWindowRect hWndChild, trcChild
cxChild = trcChild.nRight - trcChild.nLeft
cyChild = trcChild.nBottom - trcChild.nTop
' Get the limits of the 'workarea'
fResult = SystemParametersInfo(%SPI_GETWORKAREA, SIZEOF(trcWorkArea), BYVAL VARPTR(trcWorkArea), 0)
IF ISFALSE(fResult) THEN
trcWorkArea.nLeft = 0
trcWorkArea.nTop = 0
trcWorkArea.nRight = GetSystemMetrics(%SM_CXSCREEN)
trcWorkArea.nBottom = GetSystemMetrics(%SM_CYSCREEN)
END IF
' Get the Height and Width of the parent window
IF ISTRUE hWndParent THEN
GetWindowRect hWndParent, trcParent
ELSE
trcParent.nLeft = trcWorkArea.nLeft
trcParent.nTop = trcWorkArea.nTop
trcParent.nRight = trcWorkArea.nRight
trcParent.nBottom = trcWorkArea.nBottom
END IF
cxParent = trcParent.nRight - trcParent.nLeft
cyParent = trcParent.nBottom - trcParent.nTop
' Calculate new X position, then adjust for workarea
tpt.x = trcParent.nLeft + ((cxParent - cxChild) \ 2)
IF (tpt.x < trcWorkArea.nLeft) THEN
tpt.x = trcWorkArea.nLeft
ELSEIF ((tpt.x + cxChild) > trcWorkArea.nRight) THEN
tpt.x = trcWorkArea.nRight - cxChild
END IF
' Calculate new Y position, then adjust for workarea
tpt.y = trcParent.nTop + ((cyParent - cyChild) \ 2)
IF (tpt.y < trcWorkArea.nTop) THEN
tpt.y = trcWorkArea.nTop
ELSEIF ((tpt.y + cyChild) > trcWorkArea.nBottom) THEN
tpt.y = trcWorkArea.nBottom - cyChild
END IF
IF (GetWindowLong(hWndChild, %GWL_STYLE) AND %WS_CHILD) = %WS_CHILD THEN
ScreenToClient hWndParent, tpt
END IF
' Reposition the window
FUNCTION = SetWindowPos(hWndChild, %NULL, tpt.x, tpt.y, 0, 0, %SWP_NOSIZE OR %SWP_NOZORDER)
END FUNCTION
' ========================================================================================
' ========================================================================================
' FUNCTION: phnxGetFormHandle
' PURPOSE: Finds the handle of the top-level window or MDI child
' window that is the ancestor of the specified window. The
' reference handle is the handle of any control on the form.
' RETURNS: The handle of the form.
'
' ========================================================================================
FUNCTION phnxGetFormHandle ( _
BYVAL hWnd AS DWORD _ ' reference handle
) AS DWORD
WHILE ISTRUE (GetWindowLong(hWnd, %GWL_STYLE) AND %WS_CHILD)
IF ISTRUE (GetWindowLong(hWnd, %GWL_EXSTYLE) AND %WS_EX_MDICHILD) THEN EXIT LOOP
hWnd = GetParent(hWnd)
WEND
FUNCTION = hWnd
END FUNCTION
' ========================================================================================
' ========================================================================================
' Main
' ========================================================================================
FUNCTION WINMAIN ( _
BYVAL hInstance AS DWORD, _ ' handle of current instance
BYVAL hPrevInstance AS DWORD, _ ' handle of previous instance(not used in Win32)
BYVAL pszCmdLine AS ASCIIZ PTR, _ ' address of command line
BYVAL nCmdShow AS LONG _ ' show state of window
) AS LONG
LOCAL szClassName AS ASCIIZ * %MAX_PATH ' class name
LOCAL twcx AS WNDCLASSEX ' class information
LOCAL tmsg AS tagMsg ' message information
LOCAL hWnd AS DWORD ' handle of main window
LOCAL hWndModeless AS DWORD ' handle of the current active window
InitCommonControls ' // Initialize common controls (needed for XP themes)
InitXPButton ' // Initialize the XPBUTTON control
' Save the handle of the application instance
ghInstance = hInstance
' Register the Form1 window
szClassName = "XPBUTTONDEMO"
twcx.cbSize = SIZEOF(twcx) ' size of WNDCLASSEX structure
twcx.style = %CS_DBLCLKS ' class styles
twcx.lpfnWndProc = CODEPTR(Form1_WndProc) ' address of window procedure used by class
twcx.cbClsExtra = 0 ' extra class bytes
twcx.cbWndExtra = 0 ' extra window bytes
twcx.hInstance = ghInstance ' instance of the process that is registering the window
twcx.hIcon = LoadIcon(%NULL, BYVAL %IDI_APPLICATION) ' handle of class icon
twcx.hCursor = LoadCursor(%NULL, BYVAL %IDC_ARROW) ' handle of class cursor
twcx.hbrBackground = %COLOR_BTNFACE + 1 ' brush used to fill background of window's client area
twcx.lpszMenuName = %NULL ' resource identifier of the class menu
twcx.lpszClassName = VARPTR(szClassName) ' class name
twcx.hIconSm = %NULL ' handle of small icon shown in caption/system Taskbar
IF ISFALSE RegisterClassEx(twcx) THEN
FUNCTION = %TRUE
EXIT FUNCTION
END IF
' Create the Form1 window
hWnd = CreateWindowEx(%WS_EX_WINDOWEDGE, _ ' extended styles
"XPBUTTONDEMO", _ ' class name
"XPButton Demo", _ ' caption
%WS_POPUP OR %WS_VISIBLE OR %WS_CAPTION OR %WS_SYSMENU, _ ' window styles
244, 113, _ ' left, top
198, 415, _ ' width, height
%NULL, %NULL, _ ' handle of owner, menu handle
ghInstance, BYVAL %NULL) ' handle of instance, creation parameters
' If window could not be created, return "failure"
IF ISFALSE hWnd THEN
FUNCTION = %FALSE
EXIT FUNCTION
END IF
' Center the window relative to the screen
phnxCenterWindow hWnd, %NULL
' Make the window visible; update its client area
ShowWindow hWnd, nCmdShow
UpdateWindow hWnd
' Main message loop of program.
WHILE ISTRUE GetMessage(tmsg, BYVAL %NULL, 0, 0)
hWndModeless = phnxGetFormHandle(GetFocus())
IF (ISFALSE hWndModeless) OR (ISFALSE IsDialogMessage(hWndModeless, tmsg)) THEN
TranslateMessage tmsg
DispatchMessage tmsg
END IF
WEND
FUNCTION = tmsg.wParam
END FUNCTION
' ========================================================================================
' ========================================================================================
' Main window procedure
' ========================================================================================
FUNCTION Form1_WndProc ( _
BYVAL hWnd AS DWORD, _ ' window handle
BYVAL uMsg AS DWORD, _ ' type of message
BYVAL wParam AS DWORD, _ ' first message parameter
BYVAL lParam AS LONG _ ' second message parameter
) AS LONG
LOCAL hWndChild AS DWORD ' handle of child window
LOCAL hFont AS DWORD ' handle of font used by form
LOCAL lMsgResult AS LONG ' value returned to message after message is processed
SELECT CASE uMsg
CASE %WM_COMMAND
SELECT CASE LOWRD(wParam)
CASE %IDC_FORM1_ICONONLEFT
IF HIWRD(wParam) = %BN_CLICKED THEN
XPButton_SetImagePos GetDlgItem(hWnd, %IDC_FORM1_XPBUTTON), %XPBI_LEFT OR %XPBI_VCENTER, %TRUE
EXIT FUNCTION
END IF
CASE %IDC_FORM1_ICONONRIGHT
IF HIWRD(wParam) = %BN_CLICKED THEN
XPButton_SetImagePos GetDlgItem(hWnd, %IDC_FORM1_XPBUTTON), %XPBI_RIGHT OR %XPBI_VCENTER, %TRUE
EXIT FUNCTION
END IF
CASE %IDC_FORM1_NOICON
IF HIWRD(wParam) = %BN_CLICKED THEN
XPButton_SetImagePos GetDlgItem(hWnd, %IDC_FORM1_XPBUTTON), %XPBI_NONE, %TRUE
EXIT FUNCTION
END IF
CASE %IDC_FORM1_NOTEXT
IF HIWRD(wParam) = %BN_CLICKED THEN
XPButton_SetImagePos GetDlgItem(hWnd, %IDC_FORM1_XPBUTTON), %XPBI_CENTERCENTER, %TRUE
EXIT FUNCTION
END IF
CASE %IDC_FORM1_TOGGLEBUTTON
IF HIWRD(wParam) = %BN_CLICKED THEN
LOCAL fToggled AS LONG
fToggled = XPButton_GetToggle(GetDlgItem(hWnd, %IDC_FORM1_XPBUTTON))
IF ISFALSE fToggled THEN fToggled = %TRUE ELSE fToggled = %FALSE
XPButton_SetToggle GetDlgItem(hWnd, %IDC_FORM1_XPBUTTON), fToggled, %TRUE
EXIT FUNCTION
END IF
CASE %IDC_FORM1_ENABLETHEMING
IF HIWRD(wParam) = %BN_CLICKED THEN
IF XPButton_IsThemed(GetDlgItem(hWnd, %IDC_FORM1_XPBUTTON)) THEN
XPButton_DisableTheming GetDlgItem(hWnd, %IDC_FORM1_XPBUTTON)
ELSE
XPButton_EnableTheming GetDlgItem(hWnd, %IDC_FORM1_XPBUTTON)
END IF
EXIT FUNCTION
END IF
CASE %IDCLOSE
IF HIWRD(wParam) = %BN_CLICKED THEN
SendMessage hWnd, %WM_CLOSE, 0, 0
EXIT FUNCTION
END IF
END SELECT
CASE %WM_SETCURSOR
' Override the class cursor
IF GetDlgCtrlID(wParam) = %IDC_FORM1_XPBUTTON THEN
SetCursor %NULL
' Return TRUE to prevent the class cursor from being set
FUNCTION = %TRUE
EXIT FUNCTION
END IF
CASE %WM_DESTROY
PostQuitMessage 0
EXIT FUNCTION
CASE %WM_CREATE
' Create font used by container
hFont = GetStockObject(%DEFAULT_GUI_FONT)
' Create the StandardPushButton text button
hWndChild = CreateWindowEx(%NULL, _ ' extended styles
"Button", _ ' class name
"Standard PushButton", _ ' caption
%WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR _ ' window styles
%BS_PUSHBUTTON OR %BS_CENTER OR %BS_VCENTER, _ ' class styles
35, 45, _ ' left, top
121, 26, _ ' width, height
hWnd, %IDC_FORM1_STANDARDPUSHBUTTON, _ ' handle of parent, control ID
ghInstance, BYVAL %NULL) ' handle of instance, creation parameters
SendMessage hWndChild, %WM_SETFONT, hFont, %TRUE
' Create the Group1 groupbox
hWndChild = CreateWindowEx(%NULL, _ ' extended styles
"Button", _ ' class name
"Standard PushButton", _ ' caption
%WS_CHILD OR %WS_VISIBLE OR %WS_CLIPSIBLINGS OR _ ' window styles
%WS_GROUP OR _
%BS_GROUPBOX, _ ' class styles
15, 20, _ ' left, top
161, 66, _ ' width, height
hWnd, %IDC_STATIC, _ ' handle of parent, control ID
ghInstance, BYVAL %NULL) ' handle of instance, creation parameters
SendMessage hWndChild, %WM_SETFONT, hFont, %TRUE
' Create the IconOnLeft radio button
hWndChild = CreateWindowEx(%NULL, _ ' extended styles
"Button", _ ' class name
"Display Icon on Left", _ ' caption
%WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR _ ' window styles
%BS_AUTORADIOBUTTON OR %BS_LEFT OR %BS_VCENTER, _ ' class styles
35, 125, _ ' left, top
121, 21, _ ' width, height
hWnd, %IDC_FORM1_ICONONLEFT, _ ' handle of parent, control ID
ghInstance, BYVAL %NULL) ' handle of instance, creation parameters
SendMessage hWndChild, %WM_SETFONT, hFont, %TRUE
' Set the initial check state of the button
SendMessage hWndChild, %BM_CLICK, 0, 0
' Create the IconOnRight radio button
hWndChild = CreateWindowEx(%NULL, _ ' extended styles
"Button", _ ' class name
"Display Icon on Right", _ ' caption
%WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR _ ' window styles
%BS_AUTORADIOBUTTON OR %BS_LEFT OR %BS_VCENTER, _ ' class styles
35, 150, _ ' left, top
121, 21, _ ' width, height
hWnd, %IDC_FORM1_ICONONRIGHT, _ ' handle of parent, control ID
ghInstance, BYVAL %NULL) ' handle of instance, creation parameters
SendMessage hWndChild, %WM_SETFONT, hFont, %TRUE
' Create the NoIcon radio button
hWndChild = CreateWindowEx(%NULL, _ ' extended styles
"Button", _ ' class name
"No Icon", _ ' caption
%WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR _ ' window styles
%BS_AUTORADIOBUTTON OR %BS_LEFT OR %BS_VCENTER, _ ' class styles
35, 175, _ ' left, top
121, 21, _ ' width, height
hWnd, %IDC_FORM1_NOICON, _ ' handle of parent, control ID
ghInstance, BYVAL %NULL) ' handle of instance, creation parameters
SendMessage hWndChild, %WM_SETFONT, hFont, %TRUE
' Create the NoText radio button
hWndChild = CreateWindowEx(%NULL, _ ' extended styles
"Button", _ ' class name
"No Text", _ ' caption
%WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR _ ' window styles
%BS_AUTORADIOBUTTON OR %BS_LEFT OR %BS_VCENTER, _ ' class styles
35, 200, _ ' left, top
121, 21, _ ' width, height
hWnd, %IDC_FORM1_NOTEXT, _ ' handle of parent, control ID
ghInstance, BYVAL %NULL) ' handle of instance, creation parameters
SendMessage hWndChild, %WM_SETFONT, hFont, %TRUE
' Create the ToggleButton checkbox
hWndChild = CreateWindowEx(%NULL, _ ' extended styles
"Button", _ ' class name
"Toggle Button", _ ' caption
%WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR _ ' window styles
%BS_AUTOCHECKBOX OR %BS_LEFT OR %BS_VCENTER, _ ' class styles
35, 235, _ ' left, top
121, 21, _ ' width, height
hWnd, %IDC_FORM1_TOGGLEBUTTON, _ ' handle of parent, control ID
ghInstance, BYVAL %NULL) ' handle of instance, creation parameters
SendMessage hWndChild, %WM_SETFONT, hFont, %TRUE
' Create the EnableTheming checkbox
hWndChild = CreateWindowEx(%NULL, _ ' extended styles
"Button", _ ' class name
"Enable Theming", _ ' caption
%WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR _ ' window styles
%BS_AUTOCHECKBOX OR %BS_LEFT OR %BS_VCENTER, _ ' class styles
35, 260, _ ' left, top
121, 21, _ ' width, height
hWnd, %IDC_FORM1_ENABLETHEMING, _ ' handle of parent, control ID
ghInstance, BYVAL %NULL) ' handle of instance, creation parameters
SendMessage hWndChild, %WM_SETFONT, hFont, %TRUE
' Set the initial check state of the button
SendMessage hWndChild, %BM_CLICK, 0, 0
' Create the Placeholder1 control
hWndChild = CreateWindowEx(%NULL, _ ' extended styles
"XPBUTTON", _ ' class name
"XPButton", _ ' caption
%WS_CHILD OR %WS_VISIBLE OR %WS_CLIPSIBLINGS OR _ ' window styles
%WS_TABSTOP, _
35, 300, _ ' left, top
126, 26, _ ' width, height
hWnd, %IDC_FORM1_XPBUTTON, _ ' handle of parent, control ID
ghInstance, BYVAL %NULL) ' handle of instance, creation parameters
' Create the Group2 groupbox
hWndChild = CreateWindowEx(%NULL, _ ' extended styles
"Button", _ ' class name
"XPButton", _ ' caption
%WS_CHILD OR %WS_VISIBLE OR %WS_CLIPSIBLINGS OR _ ' window styles
%WS_GROUP OR _
%BS_GROUPBOX, _ ' class styles
15, 100, _ ' left, top
161, 241, _ ' width, height
hWnd, %IDC_STATIC, _ ' handle of parent, control ID
ghInstance, BYVAL %NULL) ' handle of instance, creation parameters
SendMessage hWndChild, %WM_SETFONT, hFont, %TRUE
' Create the Close text button
hWndChild = CreateWindowEx(%NULL, _ ' extended styles
"Button", _ ' class name
"Close", _ ' caption
%WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR _ ' window styles
%BS_DEFPUSHBUTTON OR %BS_CENTER OR %BS_VCENTER, _ ' class styles
100, 350, _ ' left, top
76, 26, _ ' width, height
hWnd, %IDCLOSE, _ ' handle of parent, control ID
ghInstance, BYVAL %NULL) ' handle of instance, creation parameters
SendMessage hWndChild, %WM_SETFONT, hFont, %TRUE
' Set the icons for the XPButton control
XPButton_SetIcon(GetDlgItem(hWnd, %IDC_FORM1_XPBUTTON), LoadImage(ghInstance, BYVAL 101, %IMAGE_ICON, 0, 0, %LR_DEFAULTCOLOR), %XPBI_NORMAL, %FALSE)
XPButton_SetIcon(GetDlgItem(hWnd, %IDC_FORM1_XPBUTTON), LoadImage(ghInstance, BYVAL 102, %IMAGE_ICON, 0, 0, %LR_DEFAULTCOLOR), %XPBI_HOT, %FALSE)
' Set the focus in the Close button
SetFocus GetDlgItem(hWnd, %IDCLOSE)
EXIT FUNCTION
END SELECT
FUNCTION = DefWindowProc(hWnd, uMsg, wParam, lParam)
END FUNCTION
'=========================================================================================
best regards, frank
Each function is explained in the help file for the headers, available at:
http://www.jose.it-berater.org/smfforum/index.php?topic=4425.msg15815;topicseen#msg15815
Just a quick thanx for all your help. These posts answered my questions. Ron
Sorry to re-open this old thread but ...
I'm using XPButton but compiled with PB10x it seems not working.
Button is not drawn but it seems working as a reaction of mouse click. It is just not visible.
If I XPButton_DisableTheming it returns visible
Any idea?
Thanks a lot
Eros
Eros,
I'm getting XP themed controls with IUP using thinBasic. That tells me you compiled in the manifest when building thinBasic. I don't know if this helps or not but if I try to run a DYC (FFI) based program that calls the Windows message box for example, the version of SB with manifest support won't work but a non-manifest embedded copy will.
Maybe you're experiencing a manifested state of confusion. :-\
thinBasic executable has always been a themed application and XP button worked in the past.
After compiling with PB10 it stopped showing the button but it react to messages. If I click on a XP button where it is supposed to be it correctly react to button down
It is simply not on video
If I untheme it, it returns visible
The attached example works fine in my computer.