|
|
Greetings,
I would like to write a generic CPhaseManagement object, but keep hitting a wall with it being tied to the specific app. The Phases would be something like: InitPhase, IntroPhase, MenuPhase, AppPhase, and ExitPhase with an enumerated type defined in a PhaseSettings.h file !
Each Phase of the App will have it's own specific Phase routines (StartPhase, ProcessPhase and ExitPhase). These of course will be App specific.
So I need to know how to make a pointer to a function so that the PhaseManager can call the relevant PhaseStart/exit etc.
Any pointers (haha) / comments appreciated.
If sex is a pain in the ass, then you are doing it wrong!
|
|
|
|
|
int Foo1( WPARAM, LPARAM )
{
}
int Foo2( WPARAM, LPARAM )
{
}
int (*pFunc)( WPARAM, LPARAM );
if (some_condition)
pFunc = Foo1;
else if (some_other_condition)
pFunc = Foo2;
(*pFunc)(parameter_list);
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
cast to pointer to Function hey !
Who would have thought!
(Obviously not me)
Much Appreciated
If sex is a pain in the ass, then you are doing it wrong!
|
|
|
|
|
Does this mean that I have to create a pointer to a <function with a fixed set of params> ?
As opposed to a pointer to a function with any set of params.
Obviously when I call it, I will have to pass the right param types, but do I have to declare the pointer to have those param types ?
Or am I flogging a dead camel ?
If sex is a pain in the ass, then you are doing it wrong!
|
|
|
|
|
hi,
does anyone know how to retirve information of a particular hardware device?
eg. USB devices(pc Cam)
thanks
|
|
|
|
|
You might look into GetDeviceCaps() , or the WMI functions.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
GetDeviceCaps() a CDC function to get hardware information
|
|
|
|
|
Doesn't sound quite right, does it? Forget I mentioned it!
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
I want to call some code after my dialog has been displayed on the screen. This means I cannot do it in OnInitDialog(). How can I do it?
Thank you.
|
|
|
|
|
More explanation: my dialog contains some data on startup. The user will then click the Update button and an icon is displayed on each line of data as each line is updated. I want the user to see this happen after the dialog appears but there is no message to process after the dialog is displayed. DoModal() just returns.
I think that I can create a modeless dialog instead but that is a lot of work compared to my modal one. Can I create my dialog modeless do my update and then convert to modal instead or must it remain modeless?
Is there undocumented feature which is a function that gets called after the dialog is displayed?
|
|
|
|
|
The most straightforward way is to simply post a user-defined message right before OnInitDialog() returns. This guarantees that the dialog box will be displayed and then the startup code will be executed.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
Thank you.
Can you tell me how I must do this?
|
|
|
|
|
static const UINT UDM_START_PROCESSING = ::RegisterWindowMessage(_T("UDM_START_PROCESSING"));
BEGIN_MESSAGE_MAP(CMyDialog, CDialog)
ON_REGISTERED_MESSAGE(UDM_START_PROCESSING, OnStartProcessing)
END_MESSAGE_MAP()
BOOL CMyDialog::OnInitDialog( void )
{
CDialog::OnInitDialog();
PostMessage(UDM_START_PROCESSING);
return TRUE;
}
LRESULT CMyDialog::OnStartProcessing( WPARAM, LPARAM )
{
return (0);
}
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
In your OnInitDialog() , just before you return you can show the window and it's descendants. Then you can call your Update button handler, as though the user had clicked it.
...
CDialog::OnInitDialog();
SendMessageToDescendants(WM_SHOWWINDOW, (WPARAM)TRUE);
SendMessageToDescendants(WM_ENABLE , (WPARAM)TRUE);
OnUpdate();
return TRUE;
"The folly of man is that he dreams of what he can never achieve rather than dream of what he can."
"If you think education is expensive, try ignorance."
|
|
|
|
|
Anonymous wrote:
I want to call some code after my dialog has been displayed on the screen
There may be other ways, but I would probably do this by calling a thread in your OnInitDialog function. The thread would first sleep for however long you want it to, then update your display before returning. Good luck!
Douglas A. Wright
dawrigh3@kent.edu
|
|
|
|
|
I would use a timer.
something like this:
BOOL CDlgXXX::OnInitDialog()
{
CDialog::OnInitDialog();
SetTimer(TIMER_ID, 50, NULL)
return TRUE;
}
void CDlgXXX::OnTimer(UINT nIDEvent)
{
if (TIMER_ID == nIDEvent)
{
KillTimer(TIMER_ID);
return;
}
CDialog::OnTimer(nIDEvent);
}
“Our solar system is Jupiter and a bunch of junk” - Charley Lineweaver 2002
|
|
|
|
|
Greetings All,
I have a CBitmap object and wish to derive a CTiledBitmap from it ?
What do I have to consider:
Do i have to use virtual Constructor/Destructor ?
Can I just have CBitmap as a member of CTiledBitmap ?
Any advice of how-to for derived classes ?
Cheers
If sex is a pain in the ass, then you are doing it wrong!
|
|
|
|
|
An useful question when considering whether you should model your new class as derived from some base class is the following:
A CTiledBitmap is a CBitmap ?
Or put another way:
If I change all occurrences of CBitmap with CTiledBitmap in a preexisting program, will the program still work?
I guess the answer in your particular case is no. Please note that the interface of CBitmap is not virtual, so the class is not designed with derivation in mind. Probably, a better design is to derive your CTiledBitmap from CGdiObject and have CBitmap as a private member.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanks
The CBitmap is a class of mine: should probably call it CMyBitmap ?
it has it's own constructor, loader and draw function.
So A CMyTiledBitmap is a CMyBitmap with some extra members (for the tiling info).
So, If I change all occurrences of CMyBitmap with CMyTiledBitmap in a preexisting program, the program will still work, but will have greater resource overhead.
So Why do I make the CMyBitmap constructor virtual ?
Cheers
If sex is a pain in the ass, then you are doing it wrong!
|
|
|
|
|
Hi, I'm having trouble plotting different series in the same mschart, how can I do this if each plot has a differente number of points??
Thanks!
Julihc
|
|
|
|
|
Hi,
I ma currently facing the same problem. Please let me know if you have found any solution.
Thanks!
|
|
|
|
|
As I'm a fairly new MFC programmer, I'm sure there is an easy explaination for my question. I've just run out of ideas on where to find it. I've solved this a different way than I think I should have to, and want to know why I had to.
I have options that I have placed on the file menu. I want those options to grey out if a certain boolean is set/unset. Easy so far. I added UPDATE_COMMAND_UI handlers for those options. My understanding is that each command on the File menu with an UPDATE_COMMAND_UI handler will have that handler called when the user attempts to drop down the file menu. Using breakpoints, I have discovered that this is not the case. The only time one of those handlers is called (or at least in my project) is when the particular option on the file menu is selected, and then it is the update handler for that option only. No, I have not confused COMMAND and UPDATE_COMMAND_UI. I have both, and of course each is mapped to a different function. Using OnInitMenu, I have been able to set the state of all menu items properly, but that seems to be a brute force method rather than the nicer update handlers.
This isn't the only problem menu, either. I have an options menu with a second pop-up menu with 2 options, only one of which should be checked. The update handlers would be perfect... one line of code in each handler. However, they act the same. Only when I PICK one of the options is the update handler called, concurrently with the command handler. So, I have more complex logic in the OnInitMenu function to set their checked states when the menu is opened rather than the nicer update handlers... any help, please?
|
|
|
|
|
duckpuppy wrote:
The only time one of those handlers is called (or at least in my project) is when the particular option on the file menu is selected, and then it is the update handler for that option only.
Last I read, the handlers are called during the processing of WM_IDLEUPDATECMDUI messages. This message is sent after the application has emptied its message queue.
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|