Click here to Skip to main content
15,885,366 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Two dimmensional array using pointers on Arduino Due Pin
Richard MacCutchan11-Nov-14 6:42
mveRichard MacCutchan11-Nov-14 6:42 
GeneralSOLVED Re: Two dimmensional array using pointers on Arduino Due Pin
Vaclav_11-Nov-14 8:30
Vaclav_11-Nov-14 8:30 
GeneralRe: SOLVED Re: Two dimmensional array using pointers on Arduino Due Pin
Richard MacCutchan11-Nov-14 20:57
mveRichard MacCutchan11-Nov-14 20:57 
Questionmfc Pin
adilsk009-Nov-14 19:06
adilsk009-Nov-14 19:06 
AnswerRe: mfc Pin
_Flaviu9-Nov-14 20:18
_Flaviu9-Nov-14 20:18 
AnswerRe: mfc Pin
Richard MacCutchan9-Nov-14 21:46
mveRichard MacCutchan9-Nov-14 21:46 
AnswerRe: mfc Pin
Chris Losinger10-Nov-14 3:05
professionalChris Losinger10-Nov-14 3:05 
QuestionClasses for Win32 UI and how to hide details Pin
Fernando A. Gomez F.9-Nov-14 11:19
Fernando A. Gomez F.9-Nov-14 11:19 
Hello everyone,

as an academic exercise and because, apparently, I'm founding myself with some free time to spend, I'm trying to create a set of C++ classes to abstract away the Win32 APIs related to user interface creation (I'm talking about CreateWindowEx, Translate/DispatchMessage, and so on). Yes I know I'm reinventing the wheel, and no, I don't want to use Qt nor wxWidgets; as I said, this is an academic exercise.

So, I have created a window class, which basically wraps many HWND-related functions, and adds support for children containment (as in Windows Forms Form.Controls) and event handling (using boost::signals2). I also have created derived classes (i.e. button, textbox, etc.) which I have subclassed from existing WNDCLASSes ("BUTTON", "EDIT", etc.) and have their window procedure redirected to each derived class internal methods, thus I'm able to catch any WM_ message and launch the corresponding boost::signal2 signal.

Now, in order to achieve this, I had to keep, at the very least, a HWND as a private member of my window class. What I would like to do is to abstract away this HWND, because if it appears in the header then the consumers will have windows.h #included and I'm trying to avoid this. So I turned to the pimpl idiom and did something like the following:

C++
// in window.h
class window : public container
{
  public:
    ...
  private:
    struct windata;
    std::unique_ptr<windata> _data;
};

// window.cpp
struct window::winadata
{
  HWND me;
};

window::window()
{
  ...
  _data->me = CreateWindowEx(...);
}


So this worked for window class, but then, for the derived classes, I need access to windata structure (for there is the needed HWND). Having struct windata declared as protected won't work, because in button.cpp windata is an incomplete type, and thus it won't compile.

So I'm looking for alternatives here, and wanted to ask CPians opinions on how to best achieve this abstraction. By digging on wxWidgets and other's source code, I have come up with a few alternatives:

* Have struct windata defined in its own header file and have it included in the cpps as needed.
* Create a window_base class and then have a window_win32 class inheriting window_base, and put all the Win32 specific code in the derived class (this is what wxWidgets do, I think).
* Follow the abstract factory pattern instead, which (I think) is what John Torjo does with his Win32GUI library.
* Some other options involving global variables and template voodoo.

What are your thoughts / recommendations? Thanks in advance!

modified 9-Nov-14 23:37pm.

AnswerRe: Classes for Win32 UI and how to hide details Pin
Orjan Westin10-Nov-14 2:55
professionalOrjan Westin10-Nov-14 2:55 
GeneralRe: Classes for Win32 UI and how to hide details Pin
Fernando A. Gomez F.10-Nov-14 6:57
Fernando A. Gomez F.10-Nov-14 6:57 
GeneralRe: Classes for Win32 UI and how to hide details Pin
Orjan Westin10-Nov-14 7:29
professionalOrjan Westin10-Nov-14 7:29 
AnswerRe: Classes for Win32 UI and how to hide details Pin
Aescleal11-Nov-14 2:05
Aescleal11-Nov-14 2:05 
GeneralRe: Classes for Win32 UI and how to hide details Pin
Fernando A. Gomez F.11-Nov-14 8:18
Fernando A. Gomez F.11-Nov-14 8:18 
QuestionCatching OnMouseMove on CGridCtrl Pin
_Flaviu7-Nov-14 0:31
_Flaviu7-Nov-14 0:31 
AnswerRe: Catching OnMouseMove on CGridCtrl Pin
_Flaviu7-Nov-14 0:44
_Flaviu7-Nov-14 0:44 
AnswerRe: Catching OnMouseMove on CGridCtrl Pin
Jochen Arndt7-Nov-14 1:56
professionalJochen Arndt7-Nov-14 1:56 
GeneralRe: Catching OnMouseMove on CGridCtrl Pin
_Flaviu7-Nov-14 2:30
_Flaviu7-Nov-14 2:30 
GeneralRe: Catching OnMouseMove on CGridCtrl Pin
Jochen Arndt7-Nov-14 2:40
professionalJochen Arndt7-Nov-14 2:40 
GeneralRe: Catching OnMouseMove on CGridCtrl Pin
_Flaviu9-Nov-14 20:44
_Flaviu9-Nov-14 20:44 
QuestionGetting Quotes on Call Options and Put Options Pin
BobInNJ6-Nov-14 8:35
BobInNJ6-Nov-14 8:35 
AnswerRe: Getting Quotes on Call Options and Put Options Pin
ZurdoDev6-Nov-14 10:18
professionalZurdoDev6-Nov-14 10:18 
GeneralRe: Getting Quotes on Call Options and Put Options Pin
BobInNJ6-Nov-14 11:36
BobInNJ6-Nov-14 11:36 
AnswerRe: Getting Quotes on Call Options and Put Options Pin
Richard Andrew x646-Nov-14 11:43
professionalRichard Andrew x646-Nov-14 11:43 
AnswerRe: Getting Quotes on Call Options and Put Options Pin
jschell6-Nov-14 13:29
jschell6-Nov-14 13:29 
AnswerRe: Getting Quotes on Call Options and Put Options Pin
Richard MacCutchan6-Nov-14 22:13
mveRichard MacCutchan6-Nov-14 22:13 

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.