Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 75
Default Draw a Clickable Button on XL Title Bar !

Hi all ,

I posted this question earlier on but for some reason , it didn't go thru !

Anyway... I am trying to draw a button over the XL application title bar by
using the 'CreateWindoEx' API function.However, the 'Y' parameter is related
to the Client Area of the Parent Window and therefore the Button is placed
right under the Title bar if 'Y' is set to 0 Not over it.

Any idea how to place the Button over the NonClient area of the XL
application ie:the Title Bar ?

Here is the code I have so far:


Declare Function CreateWindowEx Lib "user32" Alias "CreateWindowExA" _
(ByVal dwExStyle As Long, ByVal lpClassName As String, ByVal lpWindowName _
As String, ByVal dwStyle As Long, ByVal x As Long, ByVal y As Long, _
ByVal nWidth As Long, ByVal nHeight As Long, ByVal hWndParent As Long, _
ByVal hMenu As Long, ByVal hInstance As Long, lpParam As Any) As Long

Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, _
ByVal nCmdShow As Long) As Long

Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal _
hWndNewParent As Long) As Long

Declare Function DestroyWindow Lib "user32" _
(ByVal hwnd As Long) As Long

Const SW_NORMAL = 1
Const WS_CHILD = &H40000000
Dim lngBtnHndl As Long

Sub CreateButton()
lngBtnHndl = CreateWindowEx(0, "Button", "Test !", WS_CHILD, _
ActiveWindow.Width * 3 / 4, 0, 50, 25, Application.hwnd, 0, 0, 0)
SetParent lngBtnHndl, Application.hwnd
ShowWindow lngBtnHndl, SW_NORMAL
End Sub

Sub DestroyButton()
DestroyWindow lngBtnHndl
End Sub


Regards.



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 214
Default Draw a Clickable Button on XL Title Bar !

Hi RAFAAJ2000,
In my opinion, this cannot be done without subclassing Excel and subclassing
Excel generally causes the crash application !

Regards,
MP

"RAFAAJ2000" a écrit dans le message
de news: ...
Hi all ,

I posted this question earlier on but for some reason , it didn't go thru

!

Anyway... I am trying to draw a button over the XL application title bar

by
using the 'CreateWindoEx' API function.However, the 'Y' parameter is

related
to the Client Area of the Parent Window and therefore the Button is placed
right under the Title bar if 'Y' is set to 0 Not over it.

Any idea how to place the Button over the NonClient area of the XL
application ie:the Title Bar ?

Here is the code I have so far:


Declare Function CreateWindowEx Lib "user32" Alias "CreateWindowExA" _
(ByVal dwExStyle As Long, ByVal lpClassName As String, ByVal lpWindowName

_
As String, ByVal dwStyle As Long, ByVal x As Long, ByVal y As Long, _
ByVal nWidth As Long, ByVal nHeight As Long, ByVal hWndParent As Long, _
ByVal hMenu As Long, ByVal hInstance As Long, lpParam As Any) As Long

Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, _
ByVal nCmdShow As Long) As Long

Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal _
hWndNewParent As Long) As Long

Declare Function DestroyWindow Lib "user32" _
(ByVal hwnd As Long) As Long

Const SW_NORMAL = 1
Const WS_CHILD = &H40000000
Dim lngBtnHndl As Long

Sub CreateButton()
lngBtnHndl = CreateWindowEx(0, "Button", "Test !", WS_CHILD, _
ActiveWindow.Width * 3 / 4, 0, 50, 25, Application.hwnd, 0, 0, 0)
SetParent lngBtnHndl, Application.hwnd
ShowWindow lngBtnHndl, SW_NORMAL
End Sub

Sub DestroyButton()
DestroyWindow lngBtnHndl
End Sub


Regards.





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 75
Default Draw a Clickable Button on XL Title Bar !

Hi Michel,

Yes, you are right, it is not just the positioning of the Button over the XL
titlebar which is a nightmare but also any attempt to assign a Macro to the
Button (via Subclassing) freezes the whole application !!!

Are there any alternatives ?

Jaafar.
Regards.

"Michel Pierron" wrote:

Hi RAFAAJ2000,
In my opinion, this cannot be done without subclassing Excel and subclassing
Excel generally causes the crash application !

Regards,
MP

"RAFAAJ2000" a écrit dans le message
de news: ...
Hi all ,

I posted this question earlier on but for some reason , it didn't go thru

!

Anyway... I am trying to draw a button over the XL application title bar

by
using the 'CreateWindoEx' API function.However, the 'Y' parameter is

related
to the Client Area of the Parent Window and therefore the Button is placed
right under the Title bar if 'Y' is set to 0 Not over it.

Any idea how to place the Button over the NonClient area of the XL
application ie:the Title Bar ?

Here is the code I have so far:


Declare Function CreateWindowEx Lib "user32" Alias "CreateWindowExA" _
(ByVal dwExStyle As Long, ByVal lpClassName As String, ByVal lpWindowName

_
As String, ByVal dwStyle As Long, ByVal x As Long, ByVal y As Long, _
ByVal nWidth As Long, ByVal nHeight As Long, ByVal hWndParent As Long, _
ByVal hMenu As Long, ByVal hInstance As Long, lpParam As Any) As Long

Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, _
ByVal nCmdShow As Long) As Long

Declare Function SetParent Lib "user32" (ByVal hWndChild As Long, ByVal _
hWndNewParent As Long) As Long

Declare Function DestroyWindow Lib "user32" _
(ByVal hwnd As Long) As Long

Const SW_NORMAL = 1
Const WS_CHILD = &H40000000
Dim lngBtnHndl As Long

Sub CreateButton()
lngBtnHndl = CreateWindowEx(0, "Button", "Test !", WS_CHILD, _
ActiveWindow.Width * 3 / 4, 0, 50, 25, Application.hwnd, 0, 0, 0)
SetParent lngBtnHndl, Application.hwnd
ShowWindow lngBtnHndl, SW_NORMAL
End Sub

Sub DestroyButton()
DestroyWindow lngBtnHndl
End Sub


Regards.






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating a clickable button S Davis Excel Worksheet Functions 1 September 8th 06 04:53 PM
How can I make a clickable button to do a Key Combo? BGerman Excel Worksheet Functions 4 August 21st 06 05:01 PM
How can I draw a check box or a radio button in excel? Sunkr Excel Discussion (Misc queries) 1 March 20th 06 05:29 PM
Drawing a clickable Button over the App title bar ? RAFAAJ2000[_2_] Excel Programming 0 June 16th 05 06:46 PM
draw button Valeria Excel Programming 1 November 26th 04 12:39 PM


All times are GMT +1. The time now is 05:07 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"