Click here to Skip to main content
16,006,348 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: DLL exported function Signature Pin
User 66581-May-03 23:21
User 66581-May-03 23:21 
GeneralRe: DLL exported function Signature Pin
vikramlinux1-May-03 23:25
vikramlinux1-May-03 23:25 
GeneralRe: DLL exported function Signature Pin
David Crow2-May-03 4:43
David Crow2-May-03 4:43 
GeneralRe: DLL exported function Signature Pin
pankajdaga1-May-03 23:51
pankajdaga1-May-03 23:51 
GeneralRe: DLL exported function Signature Pin
John R. Shaw2-May-03 19:07
John R. Shaw2-May-03 19:07 
GeneralRe: DLL exported function Signature Pin
David Crow5-May-03 3:46
David Crow5-May-03 3:46 
GeneralRe: DLL exported function Signature Pin
John R. Shaw5-May-03 7:05
John R. Shaw5-May-03 7:05 
GeneralDLL question...driving me crazy though! Pin
pankajdaga1-May-03 22:58
pankajdaga1-May-03 22:58 
Hi,

I think I have hit the final roadblock in my bid to learn how to be comfortable with DLLs. I spend the whole of last night trying to figure this out, but to no avail.

I wanted to create a custom window control which all it does is draws a rectangle and blits a bitmap in it. I did it without a DLL and it worked without a hitch. Now, I used the same code and tried to write a DLL interface to it as follows:

//----------------------------------------------------------------------------------long _stdcall InitControl(HINSTANCE instance, HWND hwnd, HBITMAP hBitmap, int x, int y, int width, int height)
{
View::RegisterClass(instance);
//Offset::RegisterClass(instance);
background = new Bitmap(hBitmap);
pCtrl = new Controller(hwnd, background);
SetWinLong<controller *=""> (hwnd, pCtrl);
return 0;
}

//----------------------------------------------------------------------------------
The View::RegisterClass(instance) line is supposed to register my window control class. Using the debugger, I see that the RegisterClassEx(WNDCLASSEX) returns a non-zero value basically indicating success.

Now, in my controller class I try to create the window as:
View::MakeWindow (HWND, hwndParent, childID);

How the CreateWindowEx(...) returns zero. I verified all the parameters and they are not null. I even verified the parent handle (coming from the VB call) through Spy++ and it is indeed the same window with the right HINSTANCE. The error code string is "Cannot find window class". So, I am guessing the window did not get registered.

However, this same code works in a normal program. So, are there some rules when I am registering my own windows in a DLL. Do the parent window and the child window have to share the same DLL or something like that? I cannot understand what I am doing wrong.

Also, the VB declaration is like this:

Public Declare Function InitControl Lib "C:\BOXDLL.dll" (ByVal instance As Long, ByVal hwnd As Long, ByVal back As Long, ByVal x As Integer, ByVal y As Integer, ByVal width As Integer, ByVal height As Integer) As Long

and the call is:

InitControl App.hInstance, Me.hwnd, Me.Picture.Handle, 10, 10, 900, 200

I would really appreciate some help here. I have inching towards learning this for a whole month now and I am so close. However, this is the toughest problem I have encountered so far.

Also, I am not using MFC.

If you live around Stuttgart and help me, I will do your laundry for a week Frown | :(

Thanks,
Pankaj

Without struggle, there is no progress
GeneralRe: DLL question...driving me crazy though! Pin
John R. Shaw2-May-03 19:26
John R. Shaw2-May-03 19:26 
GeneralRe: DLL question...driving me crazy though! Pin
pankajdaga3-May-03 3:43
pankajdaga3-May-03 3:43 
Generalcreate a sine wave and sample it Pin
flora_k1-May-03 22:54
flora_k1-May-03 22:54 
GeneralRe: create a sine wave and sample it Pin
jmkhael2-May-03 3:06
jmkhael2-May-03 3:06 
GeneralRe: create a sine wave and sample it Pin
jhaga2-May-03 3:59
professionaljhaga2-May-03 3:59 
GeneralRe: create a sine wave and sample it Pin
flora_k4-May-03 22:49
flora_k4-May-03 22:49 
GeneralRe: create a sine wave and sample it Pin
jhaga5-May-03 3:17
professionaljhaga5-May-03 3:17 
GeneralRe: create a sine wave and sample it Pin
John R. Shaw2-May-03 20:16
John R. Shaw2-May-03 20:16 
GeneralAspect Ratio Setting Pin
Prog Mmer1-May-03 22:28
Prog Mmer1-May-03 22:28 
GeneralATL dll's Pin
Mazdak1-May-03 22:02
Mazdak1-May-03 22:02 
GeneralExplorer style File Dialog Pin
vin1-May-03 21:46
vin1-May-03 21:46 
GeneralRe: Explorer style File Dialog Pin
Hans Ruck2-May-03 0:51
Hans Ruck2-May-03 0:51 
QuestionDoxygen for COM? Pin
Davy Mitchell1-May-03 21:25
Davy Mitchell1-May-03 21:25 
Questionhow to apply xp theme to the vc6 projects Pin
User 160551-May-03 20:53
User 160551-May-03 20:53 
AnswerRe: how to apply xp theme to the vc6 projects Pin
Gary R. Wheeler4-May-03 3:07
Gary R. Wheeler4-May-03 3:07 
GeneralString assignment blackout Pin
Ron Levine1-May-03 20:44
Ron Levine1-May-03 20:44 
GeneralRe: String assignment blackout Pin
Toni781-May-03 21:15
Toni781-May-03 21:15 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.