Why is this working with VBA but not with VB.Net?

M

Michael Keilhack

Hello,

i try to get this working from VB.Net. Because i don't want a macro in
my Startdocument in my Visio-Solution.
I tried this code in a ComAddin, EXE-Addon and in a macro within the
document.
The WindowHandle is the right one (Spy++).

Perhaps anybody knows why this isn't working?
Is there a way to insert VBA at runtime?

Thx Michael Keilhack

Declare Function GetActiveWindow32 Lib "USER32" Alias _
"GetActiveWindow" () As Integer

Declare Function SendMessage32 Lib "USER32" Alias _
"SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long

Declare Function ExtractIcon32 Lib "SHELL32.DLL" Alias _
"ExtractIconA" (ByVal hInst As Long, _
ByVal lpszExeFileName As String, _
ByVal nIconIndex As Long) As Long

Sub SetFormIcon()
Dim h32NewIcon As Long
Dim h32WndVisMAIN As Long
Dim lResult As Long
h32NewIcon = ExtractIcon32(0, "Notepad.exe", 0)
h32WndVisMAIN = Application.WindowHandle32

lResult = SendMessage32(h32WndVisMAIN, &H80, 1, h32NewIcon)
'Iconbig

lResult = SendMessage32(h32WndVisMAIN, &H80, 0, h32NewIcon)
'Icon small

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top