Click here to Skip to main content
15,913,335 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionQuestion with Directshow Video Compression Pin
godspeed12310-Jan-07 9:08
godspeed12310-Jan-07 9:08 
AnswerRe: Question with Directshow Video Compression Pin
Mark Salsbery10-Jan-07 10:25
Mark Salsbery10-Jan-07 10:25 
GeneralRe: Question with Directshow Video Compression Pin
godspeed12310-Jan-07 10:38
godspeed12310-Jan-07 10:38 
GeneralRe: Question with Directshow Video Compression Pin
Mark Salsbery10-Jan-07 10:50
Mark Salsbery10-Jan-07 10:50 
GeneralRe: Question with Directshow Video Compression Pin
godspeed12310-Jan-07 11:01
godspeed12310-Jan-07 11:01 
GeneralRe: Question with Directshow Video Compression Pin
godspeed12310-Jan-07 11:13
godspeed12310-Jan-07 11:13 
GeneralRe: Question with Directshow Video Compression Pin
Mark Salsbery10-Jan-07 13:58
Mark Salsbery10-Jan-07 13:58 
Questionsubclassing/superclassing a button Pin
Niamorh10-Jan-07 8:13
Niamorh10-Jan-07 8:13 
Hi,
I'm trying to build a framework based on Win32 calls wich follows the .Net's one that I know better and find much easier to implement for my future projects.

Currently I'm stuck at this point :

frmMain::frmMain(HINSTANCE hinstance)
: W32Window(hinstance, LoadIcon(hinstance,MAKEINTRESOURCE(2)))
{
SetText( "MyApplication" );
Maximize();

W32Button* b = new W32Button(hinstance);

b->SetPosition(400,400,60,80);

Controls()->Add(b);
//Controls()->Remove(b);
}

You can see here that I'm trying to add a previously orphan created button to a Form.
I someone here has already played with C# or VB.Net, then he will certainly be common with this.

I have two classes W32Window and W32Button.

W32Window Class own a static function W32Window::WindowProc just as W32Button own a static function W32Button::ButtonProc.

In W32Window constructor :
- I reference WNDCLASS W32Window if it wasn't done before ( with wc.lpfnWndProc = &W32Window::WindowProc )
- I also make CreateWindow( "W32Window",...) and I hold the returned hwnd in a private member of the W32Window current object
- I finally hold a pointer to the current W32Window object with SetWindowLong(GWL_USERDATA,(LONG) (this))

In W32Window::WindowProc :
- I get the W32Window object wich sends the message : p = (W32Window*) GetWindowLong(hwnd,GWL_USERDATA)
- switching the message, I call the specified function of the object. (OnClose() function for the message WM_Destroy etc...)

This system works very well wich the windows.

I 'm currently able to make several new W32Window(hinst) and .Show() with very few code lines in the main procedure.

I would like to do the same with buttons but the are some problems.

I like the way I call the specified object functions in the message handling procedure and I would like to keep the same idea for button.

But the Win32 class is already coded, so I first thought that I had to do a global subclassing, or a superclassing to give to the button his own lpfnWndProc.

Here is that I wrote in the W32Button constructor:

W32Button::W32Button(HINSTANCE hinstance)
{
static bool boo = false;

if (!boo)
{
WNDCLASS wc;
GetClassInfo(hinstance,"button",&wc);

wc.lpfnWndProc = &W32Button::ButtonProc;
wc.hInstance = hinstance;

wc.lpszClassName = "W32Button";

RegisterClass(&wc);
}

hwnd = CreateWindow("W32Button", "butt", WS_OVERLAPPED,
0, 0, 0, 0,
NULL, NULL, hinstance, NULL);

LONG style = WS_CHILD | WS_VISIBLE;
SetWindowLong(hwnd,GWL_STYLE,style);
SetWindowLong(hwnd, GWL_USERDATA, reinterpret_cast<long> (this));
SetPosition(0,0,20,20);
}

Then latter, in the Controls()->Add(b) :

void
W32WndCollection::Add(W32Wnd *w)
{
if ( Contains( w ) ) return;
m_wnds.push_back( w );
SetParent( w->getHWND() , m_container->getHWND() );
}

It work very well if I use a basic "button" control in the createwindow function, but if i superclass or subclass the button, my button does not display anymore...

Here is the code of button proc :

LRESULT WINAPI
W32Button::ButtonProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
W32Button* w = reinterpret_cast<w32button*> (GetWindowLongA(hwnd, GWL_USERDATA));

//return DefWindowProc(hwnd, uMsg, wParam, lParam);
return CallWindowProc( &W32Window::WindowProc , hwnd, uMsg, wParam, lParam);
}

I've tried both uncommented and commented return with no result...

Can someone help please?
Sorry for having beeing long.
AnswerRe: subclassing/superclassing a button Pin
Mark Salsbery10-Jan-07 8:36
Mark Salsbery10-Jan-07 8:36 
GeneralRe: subclassing/superclassing a button Pin
Niamorh11-Jan-07 4:20
Niamorh11-Jan-07 4:20 
GeneralRe: subclassing/superclassing a button Pin
Mark Salsbery11-Jan-07 4:37
Mark Salsbery11-Jan-07 4:37 
QuestionOpen File Dialog PocketPC Pin
Like2Byte10-Jan-07 8:08
Like2Byte10-Jan-07 8:08 
QuestionImageList_DrawIndirect Problem! Pin
r3dqu33n10-Jan-07 6:15
r3dqu33n10-Jan-07 6:15 
QuestionRe: ImageList_DrawIndirect Problem! Pin
Mark Salsbery10-Jan-07 7:33
Mark Salsbery10-Jan-07 7:33 
AnswerRe: ImageList_DrawIndirect Problem! Pin
r3dqu33n10-Jan-07 8:36
r3dqu33n10-Jan-07 8:36 
GeneralRe: ImageList_DrawIndirect Problem! Pin
Mark Salsbery10-Jan-07 8:42
Mark Salsbery10-Jan-07 8:42 
QuestionProblem with CMap GetStartPosition() Pin
vipin_nvk10-Jan-07 5:22
vipin_nvk10-Jan-07 5:22 
AnswerRe: Problem with CMap GetStartPosition() Pin
PJ Arends10-Jan-07 5:56
professionalPJ Arends10-Jan-07 5:56 
QuestionRe: Problem with CMap GetStartPosition() Pin
David Crow10-Jan-07 5:59
David Crow10-Jan-07 5:59 
QuestionWhat's the problem of my program? Pin
Ming Luo10-Jan-07 5:15
Ming Luo10-Jan-07 5:15 
AnswerRe: What's the problem of my program? Pin
Roger Stoltz10-Jan-07 5:36
Roger Stoltz10-Jan-07 5:36 
GeneralRe: What's the problem of my program? Pin
PJ Arends10-Jan-07 6:02
professionalPJ Arends10-Jan-07 6:02 
GeneralRe: What's the problem of my program? Pin
Roger Stoltz10-Jan-07 6:11
Roger Stoltz10-Jan-07 6:11 
QuestionSending File Through UDP Pin
Girish60110-Jan-07 4:14
Girish60110-Jan-07 4:14 
AnswerRe: Sending File Through UDP Pin
Roger Stoltz10-Jan-07 4:36
Roger Stoltz10-Jan-07 4:36 

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.