PC Review


Reply
Thread Tools Rate Thread

CreateWindowEx

 
 
JP Ronse
Guest
Posts: n/a
 
      24th Aug 2009
Hi All,

Has someone already written some 'free' code in Excel VBA (2003) using the
CreateWindowEx API, send some text to it and close it by user action? I
really would to consult it if you don't mind. I find a lot of samples but
most are written for VB and do not work in Excel.

I know, it can be done also with a userform but I would like it to try it
once this way.

Many thanks for your replies.

Wkr,

JP


 
Reply With Quote
 
 
 
 
Joel
Guest
Posts: n/a
 
      25th Aug 2009
I found a website with code that didn't work Made two small changes

http://www.bigresource.com/VB-Create...RpKvdIZhW.html

Change this line. I changes "ME" and "APP" to "Application"
mWnd = CreateWindowEx(WS_EX_STATICEDGE Or WS_EX_TRANSPARENT, "STATIC",
"Sample!!!", WS_CHILD, 0, 0, 300, 50, Application.hwnd, 0,
Application.hInstance, CS)




Const WS_CHILD = &H40000000
Const CW_USEDEFAULT = &H80000000
Const SW_NORMAL = 1
Private Type CREATESTRUCT
lpCreateParams As Long
hInstance As Long
hMenu As Long
hWndParent As Long
cy As Long
cx As Long
y As Long
x As Long
style As Long
lpszName As String
lpszClass As String
ExStyle As Long
End Type
Private 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
Private Declare Function DestroyWindow Lib "user32" (ByVal hwnd As Long) As
Long
Dim mWnd As Long

Private Sub Form_Load()
Dim CS As CREATESTRUCT
'Create a new label
mWnd = CreateWindowEx(WS_EX_STATICEDGE Or WS_EX_TRANSPARENT, "STATIC",
"Sample!!!", WS_CHILD, 0, 0, 300, 50, Application.hwnd, 0,
Application.hInstance, CS)
'Me.Caption = mWnd
'Show our label
ShowWindow mWnd, SW_NORMAL
End Sub
Private Sub Form_Unload(Cancel As Integer)
'destroy our label
DestroyWindow mWnd
End Sub



"JP Ronse" wrote:

> Hi All,
>
> Has someone already written some 'free' code in Excel VBA (2003) using the
> CreateWindowEx API, send some text to it and close it by user action? I
> really would to consult it if you don't mind. I find a lot of samples but
> most are written for VB and do not work in Excel.
>
> I know, it can be done also with a userform but I would like it to try it
> once this way.
>
> Many thanks for your replies.
>
> Wkr,
>
> JP
>
>
>

 
Reply With Quote
 
JP Ronse
Guest
Posts: n/a
 
      25th Aug 2009
Hi Joel,

Thanks for your time, I'll have a look and will give feedback.

Wkr,

JP

"Joel" <(E-Mail Removed)> wrote in message
news:264C7CC3-FE73-4745-9621-(E-Mail Removed)...
>I found a website with code that didn't work Made two small changes
>
> http://www.bigresource.com/VB-Create...RpKvdIZhW.html
>
> Change this line. I changes "ME" and "APP" to "Application"
> mWnd = CreateWindowEx(WS_EX_STATICEDGE Or WS_EX_TRANSPARENT, "STATIC",
> "Sample!!!", WS_CHILD, 0, 0, 300, 50, Application.hwnd, 0,
> Application.hInstance, CS)
>
>
>
>
> Const WS_CHILD = &H40000000
> Const CW_USEDEFAULT = &H80000000
> Const SW_NORMAL = 1
> Private Type CREATESTRUCT
> lpCreateParams As Long
> hInstance As Long
> hMenu As Long
> hWndParent As Long
> cy As Long
> cx As Long
> y As Long
> x As Long
> style As Long
> lpszName As String
> lpszClass As String
> ExStyle As Long
> End Type
> Private 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
> Private Declare Function DestroyWindow Lib "user32" (ByVal hwnd As Long)
> As
> Long
> Dim mWnd As Long
>
> Private Sub Form_Load()
> Dim CS As CREATESTRUCT
> 'Create a new label
> mWnd = CreateWindowEx(WS_EX_STATICEDGE Or WS_EX_TRANSPARENT, "STATIC",
> "Sample!!!", WS_CHILD, 0, 0, 300, 50, Application.hwnd, 0,
> Application.hInstance, CS)
> 'Me.Caption = mWnd
> 'Show our label
> ShowWindow mWnd, SW_NORMAL
> End Sub
> Private Sub Form_Unload(Cancel As Integer)
> 'destroy our label
> DestroyWindow mWnd
> End Sub
>
>
>
> "JP Ronse" wrote:
>
>> Hi All,
>>
>> Has someone already written some 'free' code in Excel VBA (2003) using
>> the
>> CreateWindowEx API, send some text to it and close it by user action? I
>> really would to consult it if you don't mind. I find a lot of samples but
>> most are written for VB and do not work in Excel.
>>
>> I know, it can be done also with a userform but I would like it to try it
>> once this way.
>>
>> Many thanks for your replies.
>>
>> Wkr,
>>
>> JP
>>
>>
>>



 
Reply With Quote
 
JP Ronse
Guest
Posts: n/a
 
      25th Aug 2009
Hi Joel,

It is working!!! Thank you very much.

Wkr,

JP


"Joel" <(E-Mail Removed)> wrote in message
news:264C7CC3-FE73-4745-9621-(E-Mail Removed)...
>I found a website with code that didn't work Made two small changes
>
> http://www.bigresource.com/VB-Create...RpKvdIZhW.html
>
> Change this line. I changes "ME" and "APP" to "Application"
> mWnd = CreateWindowEx(WS_EX_STATICEDGE Or WS_EX_TRANSPARENT, "STATIC",
> "Sample!!!", WS_CHILD, 0, 0, 300, 50, Application.hwnd, 0,
> Application.hInstance, CS)
>
>
>
>
> Const WS_CHILD = &H40000000
> Const CW_USEDEFAULT = &H80000000
> Const SW_NORMAL = 1
> Private Type CREATESTRUCT
> lpCreateParams As Long
> hInstance As Long
> hMenu As Long
> hWndParent As Long
> cy As Long
> cx As Long
> y As Long
> x As Long
> style As Long
> lpszName As String
> lpszClass As String
> ExStyle As Long
> End Type
> Private 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
> Private Declare Function DestroyWindow Lib "user32" (ByVal hwnd As Long)
> As
> Long
> Dim mWnd As Long
>
> Private Sub Form_Load()
> Dim CS As CREATESTRUCT
> 'Create a new label
> mWnd = CreateWindowEx(WS_EX_STATICEDGE Or WS_EX_TRANSPARENT, "STATIC",
> "Sample!!!", WS_CHILD, 0, 0, 300, 50, Application.hwnd, 0,
> Application.hInstance, CS)
> 'Me.Caption = mWnd
> 'Show our label
> ShowWindow mWnd, SW_NORMAL
> End Sub
> Private Sub Form_Unload(Cancel As Integer)
> 'destroy our label
> DestroyWindow mWnd
> End Sub
>
>
>
> "JP Ronse" wrote:
>
>> Hi All,
>>
>> Has someone already written some 'free' code in Excel VBA (2003) using
>> the
>> CreateWindowEx API, send some text to it and close it by user action? I
>> really would to consult it if you don't mind. I find a lot of samples but
>> most are written for VB and do not work in Excel.
>>
>> I know, it can be done also with a userform but I would like it to try it
>> once this way.
>>
>> Many thanks for your replies.
>>
>> Wkr,
>>
>> JP
>>
>>
>>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
NullReferenceException in UnsafeNativeMethods.CreateWindowEx Tester Microsoft Dot NET Framework Forms 13 16th Jul 2004 01:05 AM
CreateWindowEx / RegisterClass James L Microsoft Dot NET Compact Framework 2 6th Dec 2003 07:59 PM
createwindowex api call Tony Microsoft VB .NET 3 3rd Nov 2003 06:02 AM
Using CreateWindowEx API to create a RichTextBox Patrick Blackman Microsoft C# .NET 1 15th Jul 2003 09:54 PM
P/Invoke to CreateWindowEx() Nandakumar Sankaran Microsoft Dot NET Compact Framework 4 12th Jul 2003 10:33 PM


Features
 

Advertising
 

Newsgroups
 


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