Solved

Calling DialogBox() from within a DLL

Posted on 1998-11-23
3
243 Views
Last Modified: 2013-12-03
I am trying to call DialogBox() from within a DLL, every time I do, it gives me a GPF in KRNL386.  If I do the EXACT same DialogBox() call in an EXE, it works fine.  I am using Borland C++ 4.52 and the documentation hints that I should NOT use the MakeProcInstance() call if it is being used in a DLL.  I have tried removing the MakeProcInstance() calls but it still GPF's.  Another kicker is this MUST be written using 16-bit API calls  :(

Any idea's on how to correctly call the DialogBox() function from within a DLL? (the DLL has no window of it's own).
0
Comment
Question by:marlow
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 8

Accepted Solution

by:
Answers2000 earned 200 total points
ID: 1416282
Do not call DialogBox from LibMain under Win16.  It will work if you call it from a custom procedure (DLL entry point)

Code to do dialog boxes in DLLs should be identical IIRC

Incidentally make sure the host app has a message loop.
0
 

Author Comment

by:marlow
ID: 1416283
Need more info...

The DialogBox() function is called from within one of my procedures in my DLL, not from LibMain.  What did you say the code to do dialog boxes in DLL's are identical to?  I did not understand...

Yes, host app has message loop...
0
 
LVL 8

Expert Comment

by:Answers2000
ID: 1416284
Yes the code is identical for the actual dialog box itself, to code for a dialog in an EXE.  This is actual a good way to debug/develop a dialog - as you simply write the code in an EXE and then cut/paste it to your DLL.

The DLL will rely on the main app's message loop

Also with DLL version make sure you use the correct hInst where the resource lies (presumably that of the DLL itself).  

0

Featured Post

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

630 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question