Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 12
Default Passing a handle from Excel to a dll

Hi

I'm opening a window in a dll using VBA in excel
When the window is open I get 2 icons on the taskbar one for Excel and one
for the window.

Therefore I want to pass a handle from Excel to the window in the dll so I
only get one icon on the taskbar

C++ code in dll:

extern "C" __declspec(dllexport)void __stdcall Show_PickCalcForm(int &Modal,
HWND CallingApp)

But how do I call this function using VBA?

This is what I have now:
Declare Sub Excel_PickCalcForm Lib "BaseCalc.dll" (ByRef Modal As Long,
????)

Can anyone tell me what to write as the last argument and how to use the
function?

Thanks Torben



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.786 / Virus Database: 532 - Release Date: 29/10/2004


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default Passing a handle from Excel to a dll

1st:
you have to be very carefull with passing arguments byref.
2nd:
whether you get several windows on the taskbar or only one depends
on the option Windows in Taskbar in Tools/options/View
3rd:
do you want to pass the window handle of the application or the child
window of the workbook?

I'll assume the latter.

in windows XP and newer (i dont know about xl2000)
application.hwnd will you the handle to the application.window


However to keep it simple and compatible, my proc will just use
findwindowex to locate the window.

For the fun of it I've coded it as a Property of thisworkbook,
but of course you can put it in a normal module AND pass a workbook
argument

'Thisworkbook Module
Option Explicit

Private Declare Function FindWindowEx _
Lib "user32" Alias "FindWindowExA" _
(ByVal hWnd1 As Long, ByVal hWnd2 As Long, _
ByVal lpsz1 As String, _
ByVal lpsz2 As String) As Long

Property Get WorkbookHnd() As Long
Dim lp As Long
'Application
lp = FindWindowEx(0&, 0&, "XLMAIN", Application.Caption)
'Desktop
lp = FindWindowEx(lp, 0&, "XLDESK", vbNullString)
'Workbook
WorkbookHnd = FindWindowEx(lp, 0&, "EXCEL7", Me.Windows(1).Caption)

End Property


Sub test()
Dim l&
l = Me.WorkbookHnd

End Sub







--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam

Torben Laursen wrote in message
:

Hi

I'm opening a window in a dll using VBA in excel
When the window is open I get 2 icons on the taskbar one for Excel and
one for the window.

Therefore I want to pass a handle from Excel to the window in the dll
so I only get one icon on the taskbar

C++ code in dll:

extern "C" __declspec(dllexport)void __stdcall Show_PickCalcForm(int
&Modal, HWND CallingApp)

But how do I call this function using VBA?

This is what I have now:
Declare Sub Excel_PickCalcForm Lib "BaseCalc.dll" (ByRef Modal As
Long, ????)

Can anyone tell me what to write as the last argument and how to use
the function?

Thanks Torben



---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.786 / Virus Database: 532 - Release Date: 29/10/2004




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
How many entries can Excel handle!? Rebecca Sage Excel Discussion (Misc queries) 7 March 26th 10 07:22 AM
what is "fill handle". i don't see any fill handle in my excel Neelakanta New Users to Excel 32 June 18th 08 12:48 PM
Fill handle turned into a move handle Northwoods Excel Discussion (Misc queries) 1 March 2nd 07 03:40 PM
To many rows for EXCEL to handle moglione1 Excel Discussion (Misc queries) 3 September 9th 05 02:52 PM
Am I trying to do something that Excel cannot handle? KG Excel Discussion (Misc queries) 1 February 20th 05 01:40 PM


All times are GMT +1. The time now is 02:26 PM.

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"