Click here to Skip to main content
15,893,594 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: CArchive File Format? Pin
Neville Franks23-Sep-02 16:21
Neville Franks23-Sep-02 16:21 
AnswerRe: CArchive File Format? Pin
Ravi Bhavnani23-Sep-02 17:42
professionalRavi Bhavnani23-Sep-02 17:42 
GeneralEnumWindows... Pin
adamUK23-Sep-02 11:56
adamUK23-Sep-02 11:56 
GeneralRe: EnumWindows... Pin
Joaquín M López Muñoz23-Sep-02 12:00
Joaquín M López Muñoz23-Sep-02 12:00 
GeneralRe: EnumWindows... Pin
adamUK23-Sep-02 21:45
adamUK23-Sep-02 21:45 
GeneralMake sure it's a static function Pin
TyMatthews23-Sep-02 12:57
TyMatthews23-Sep-02 12:57 
GeneralRe: Make sure it's a static function Pin
adamUK23-Sep-02 21:43
adamUK23-Sep-02 21:43 
GeneralRe: Make sure it's a static function Pin
Daniel Lohmann24-Sep-02 8:28
Daniel Lohmann24-Sep-02 8:28 
Okay, now you have managed level 1, let's go up to level 2 Big Grin | :-D

Using only static member functions (also called class functions) or ordinary C functions as callbacks is boring and odd. But you can use adapters to "translate" a call to a static function seamless into a call to a real member function.

If you are interested in more technical details about the "callback has to be static" issue and a complete solution for it you may want to check out my article Use member functions for C-style callbacks and threads - a general solution.

However, you don't have to read the whole article, you could also just use the provided adapters. It allows you to write code as simple as the following:
#include "stdafx.h"
#include "win_adapter.h" // This file contains all you need


struct DATA { int foo; double bar; };


class Test
{
public:
    // Callback for EnumWindows using a user defined type for the UserData parameter
    // You can pass there anything you want
    virtual BOOL WindowLister( HWND hWnd, const DATA& data )
    {
        printf("  Window: %p\n",  hWnd );
        return true;
    }

    // Some function that needs to enumerate windows
    void DoStuff()
    {
        // Calling EnumWindows with a member function as callback
        DATA someData;
        win::EnumWindows( this, &Test::WindowLister, someData );
     }
};


Programming is fun! Cool | :cool:

--

Daniel Lohmann

http://www.losoft.de
(Hey, this page is worth looking! You can find some free and handy NT tools there Big Grin | :-D )
Generalwindow smoothing on static controls Pin
Anonymous23-Sep-02 11:42
Anonymous23-Sep-02 11:42 
GeneralRe: window smoothing on static controls Pin
Shog923-Sep-02 12:35
sitebuilderShog923-Sep-02 12:35 
Questionlocation of dll on users machine. Where to put it? Pin
ns23-Sep-02 11:22
ns23-Sep-02 11:22 
AnswerRe: location of dll on users machine. Where to put it? Pin
Joaquín M López Muñoz23-Sep-02 11:30
Joaquín M López Muñoz23-Sep-02 11:30 
Generalthanks very much Pin
ns23-Sep-02 11:32
ns23-Sep-02 11:32 
Generalproblem with pasting bitmap into a clipboard Pin
Mariusz Popiolek23-Sep-02 9:57
sussMariusz Popiolek23-Sep-02 9:57 
GeneralRe: problem with pasting bitmap into a clipboard Pin
Joaquín M López Muñoz23-Sep-02 11:18
Joaquín M López Muñoz23-Sep-02 11:18 
GeneralRe: problem with pasting bitmap into a clipboard Pin
Mariusz Popiolek24-Sep-02 0:28
sussMariusz Popiolek24-Sep-02 0:28 
GeneralRe: problem with pasting bitmap into a clipboard Pin
Tomasz Sowinski24-Sep-02 0:07
Tomasz Sowinski24-Sep-02 0:07 
GeneralAttn: Shell Gurus Pin
Turtle needs Shell help23-Sep-02 9:53
sussTurtle needs Shell help23-Sep-02 9:53 
GeneralRe: Attn: Shell Gurus Pin
Stephane Rodriguez.23-Sep-02 11:21
Stephane Rodriguez.23-Sep-02 11:21 
GeneralRe: Attn: Shell Gurus Pin
Stephane Rodriguez.24-Sep-02 5:32
Stephane Rodriguez.24-Sep-02 5:32 
GeneralNew to computer programming Pin
Brandinimo23-Sep-02 9:30
Brandinimo23-Sep-02 9:30 
GeneralRe: New to computer programming Pin
Joaquín M López Muñoz23-Sep-02 9:41
Joaquín M López Muñoz23-Sep-02 9:41 
GeneralRe: New to computer programming Pin
SanShou23-Sep-02 9:52
SanShou23-Sep-02 9:52 
GeneralRe: New to computer programming Pin
Atlantys23-Sep-02 10:09
Atlantys23-Sep-02 10:09 
GeneralRe: New to computer programming Pin
mystro_AKA_kokie23-Sep-02 10:03
mystro_AKA_kokie23-Sep-02 10:03 

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.