Major DLL issues, symbols exported, but still unidentified.

Please support our C++ advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jul 2008
Posts: 45
Reputation: killdude69 is an unknown quantity at this point 
Solved Threads: 1
killdude69 killdude69 is offline Offline
Light Poster

Major DLL issues, symbols exported, but still unidentified.

 
0
  #1
Jun 19th, 2009
This problem has been bugging me for two days now.

I am trying to make a DLL, it exports many classes containing properties, variables, functions and a constructor.

I am using VC++ 2005 on Windows Vista Basic.

My project is the WGCL C++ control library. It is a mask for the WinAPI common controls. And since the files are so big, they all must be in their own header.

My goal is for the dll to be loaded with LoadLibrary only, no linker options, nothing else at all.

Which I know is possible because Scintilla does this.

Here is what I have:

WGCL2.cpp
  1. #define WGCL_VERSION 0x0200
  2.  
  3. #include <windows.h>
  4. #include <commctrl.h>
  5.  
  6. #define DLLEXPORT __declspec(dllexport)
  7.  
  8. #include "TextBox.h"
  9.  
  10. BOOL APIENTRY DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
  11. {
  12. return TRUE;
  13. }

TextBox.h
  1. #define WGCL_TEXTBOX
  2.  
  3. class DLLEXPORT TextBox
  4. {
  5. private:
  6. // Underlying Property Variables
  7. LPSTR _Text;
  8. HWND _hwnd, _Parent;
  9. bool _MultiLine; // ReadOnly, after Set
  10. bool _Visible;
  11. bool _Enabled;
  12. bool _ReadOnly;
  13. int _x, _y;
  14. int _width, _height;
  15. int _ControlID; // ReadOnly, after Set
  16. public:
  17. // Underlying Property Get() & Set(val) Operations
  18. LPSTR Text_Get()
  19. {
  20. LPSTR buffer;
  21. buffer = (LPSTR)GlobalAlloc(GPTR, (GetWindowTextLength(hwnd) + 1));
  22. GetWindowText(hwnd, buffer, (GetWindowTextLength(hwnd) + 1));
  23. return buffer;
  24. }
  25. void Text_Set(LPSTR val) { _Text = val; SetWindowText(hwnd, Text); }
  26. HWND hwnd_Get() { return _hwnd; }
  27. void hwnd_Set(HWND val) { _hwnd = val; }
  28. HWND Parent_Get() { return _Parent; }
  29. void Parent_Set(HWND val) { _Parent = val; }
  30. bool MultiLine_Get() { return _MultiLine; }
  31. bool Visible_Get() { return _Visible; }
  32. void Visible_Set(bool val)
  33. {
  34. _Visible = val;
  35. if (val == true)
  36. ShowWindow(_hwnd, SW_SHOW);
  37. else
  38. ShowWindow(_hwnd, SW_HIDE);
  39. }
  40. bool CanUndo_Get() { return FromBOOL(Send(EM_CANUNDO, 0, 0)); }
  41. bool ReadOnly_Get() { return _ReadOnly; }
  42. void ReadOnly_Set(bool val) { if(Send(EM_SETREADONLY, val, 0)) _ReadOnly = val; }
  43. bool Enabled_Get() { return _Enabled; }
  44. void Enabled_Set(bool val) { if(EnableWindow(_hwnd, val)) _Enabled = val; }
  45. int X_Get() { return _x; }
  46. void X_Set(int val) { _x = val; Resize(_x, _y, _width, _height); }
  47. int Y_Get() { return _y; }
  48. void Y_Set(int val) { _y = val; Resize(_x, _y, _width, _height); }
  49. int Width_Get() { return _width; }
  50. void Width_Set(int val) { if(Resize(_x, _y, _width, _height)) _width = val; }
  51. int Height_Get() { return _height; }
  52. void Height_Set(int val) { if(Resize(_x, _y, _width, _height)) _height = val; }
  53. int ControlID_Get() { return _ControlID; }
  54. int TextLength_Get() { return GetWindowTextLength(_hwnd); }
  55.  
  56. // Constuctor
  57. TextBox::TextBox(LPSTR, HWND, bool, int, int, int, int, int);
  58.  
  59. // Properties
  60. _declspec( property( get=Text_Get, put=Text_Set ) ) LPSTR Text;
  61. _declspec( property( get=hwnd_Get ) ) HWND hwnd;
  62. _declspec( property( get=Parent_Get, put=Parent_Set ) ) HWND Parent;
  63. _declspec( property( get=MultiLine_Get ) ) bool MultiLine;
  64. _declspec( property( get=Visible_Get, put=Visible_Set ) ) bool Visible;
  65. _declspec( property( get=CanUndo_Get ) ) bool CanUndo;
  66. _declspec( property( get=ReadOnly_Get, put=ReadOnly_Set ) ) bool ReadOnly;
  67. _declspec( property( get=Enabled_Get, put=Enabled_Set ) ) bool Enabled;
  68. _declspec( property( get=ControlID_Get ) ) int ControlID;
  69. _declspec( property( get=X_Get, put=X_Set ) ) int x;
  70. _declspec( property( get=Y_Get, put=Y_Set ) ) int y;
  71. _declspec( property( get=Width_Get, put=Width_Set ) ) int width;
  72. _declspec( property( get=Height_Get, put=Height_Set ) ) int height;
  73. _declspec( property( get=TextLength_Get ) ) int TextLength;
  74.  
  75. // Functions
  76. bool Create();
  77. bool Update();
  78. bool Destroy();
  79.  
  80. bool FitToWindow();
  81. bool Resize(int, int, int, int);
  82. bool SetPos(HWND, int, int, int, int, UINT);
  83.  
  84. void Undo();
  85. void Cut();
  86. void Copy();
  87. void Paste();
  88. void Delete();
  89. void Clear();
  90.  
  91. LRESULT Send(UINT, WPARAM, LPARAM);
  92. };
  93.  
  94. TextBox::TextBox(LPSTR text_, HWND parent_, bool multiline_, int x_, int y_, int width_, int height_, int controlid_)
  95. {
  96. _Text = text_;
  97. _Parent = parent_;
  98. _x = x_;
  99. _y = y_;
  100. _width = width_;
  101. _height = height_;
  102. _ControlID = controlid_;
  103.  
  104. _Enabled = true;
  105. _ReadOnly = false;
  106. }

That is a little over half of the code of TextBox.h, now you see why they must be in different files.

When I use LoadLibrary to load the dll, the compiler says the symbols are loaded. But when I try to create an object with the TextBox class, it says "error C2065: 'TextBox' : undeclared identifier".

I know it is because the class is not exporting correctly. But what I don't know is how to import and export them correctly. I have searched all kinds of websites, from MSDN to CodeProject. And to no success.

How could I export the various functions, variables, constructors and enums from my DLL and import them into my application.

Thanks in advance.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum


Views: 324 | Replies: 0
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC