|
cedric moonen wrote:
typedef BOOL __stdcall (*PROC2)(int,int,int,int,int,int);
hummm, interresting... ;P
cedric moonen wrote:
the syntax may be a little bit wrong because I never remember correctly how to typedef functions prototypes
nop, you're totally right ! great sir !
TOXCCT >>> GEII power [toxcct][VisualCalc]
-- modified at 8:26 Friday 26th August, 2005
|
|
|
|
|
Yes, that reminds me of a recent discussion
|
|
|
|
|
Thanks but I already tried this (should have told you before). The syntax has to be BOOL (__stdcall *function). BOOL __stdcall(*function) generates an error message.
If I read all the articles about calling conventions, they learn me that the main difference is in cleaning up the stack. If I read the documentation on this topic in the ms visual c++ help documentation, they only talk about __cdecl __stdcall and __fastcall. But according to this doccumentation, the cleaning-up of the stack is the same for all 3 conventions.
I'm a little confused (maybe not due to this problem) right now.
Would you have any other suggestion fo me?
Thanks in advance
|
|
|
|
|
Hi,
__cdecl is differs from other calling conventions. __cdecl is used for C calling convention.
To be clear about the stack clean up assume the following senario.
In "C", we have an option to pass variable number of parameters to a fucntion.
Generall the function would be defined a
void Add(...)
{
}
you can call this function like
void main()
{
Add(10);
Add(10,20,30);
}
In the above case , caller knows how many parameter is passed to that Add function. Add() function has no clue about how many parameter has been passed to it. In this case Add() function cannot not do stack clean up, becasue it has no clue how many paramter passed ..
Hence here is, caller responsibe to clean up the stack of Add() function, because it knew how many parameter had been passed...
But in case of __stdcall convetion, there are a lot of articles in codeproject, net, usenet available. __stdcall forces that the number of parameter passed to a function must be defined so that the called function can do clean up the stack.
In your code, you have declared a function pointer which is not __stdcall specified. But the funtion you calling is using __stdcall convention. You are calling that function using a function pointer. According to your compiler, you function pointer is following __cdecl because no calling convention specified in your code.
(*fun) ( );
When you call the function, as per __stdcall standard, your called function will do stack clean up. Hence stack is already cleaned...
In the next line, now the caller responsiblity to do clean , because your declaration says your function pointer is follwoing __cdecl convention which mean caller has to clean up the stack.. So the caller tried to clean up not existing stack (Becuase it is already cleaned), hence an error.
Hope you understand this
" Action without vision is only passing time,
Vision without action is merely day dreaming,
But vision with action can change the world "
- Words from Nelson Mandela
Thanks & Regards,
Gopalakrishnan
|
|
|
|
|
j.dinjens wrote:
If I read all the articles about calling conventions, they learn me that the main difference is in cleaning up the stack. If I read the documentation on this topic in the ms visual c++ help documentation, they only talk about __cdecl __stdcall and __fastcall. But according to this doccumentation, the cleaning-up of the stack is the same for all 3 conventions.
I'm a little confused :confusedmaybe not due to this problem) right now.
A __stdcall function’s arguments are pushed onto the stack from right to left, and the called function pops these arguments from the stack before it returns. It cannot be used with a variable-argument function. A __cdecl function’s arguments are pushed onto the stack from right to left, and the stack is cleaned up by the caller.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
Hi
I have developed and simple MFC, dialogue based application. Nothing in it.
Now i want to get the HWND(handle) of my Window then what functions to use ?
Any help plz
Regards,
Amarelia Maehsh
Gujarat
India
|
|
|
|
|
GetSafeHwnd
He is smart. He will make our Windows go.
|
|
|
|
|
Hi,
When you need window handle for main window, your can call AfxGetMainWnd ()->GetSafeHwnd() function. this is call from outside window object... From your window object you can getsafehwnd()
" Action without vision is only passing time,
Vision without action is merely day dreaming,
But vision with action can change the world "
- Words from Nelson Mandela
Thanks & Regards,
Gopalakrishnan
|
|
|
|
|
Hi,
If I have a popup menu (in HMENU form) which I'm just about to display as the context menu, how is it possible to get the CmdUpdateUI system to update all the commands in the menu with their relevant check states, disabled states etc.? This doesn't seem to happen automatically!
Joel Holdsworth
|
|
|
|
|
One method would be to have the MainFrame() the owner of the menu in the call to TrackPopupMenu(). The other would be to look at the code for
void CFrameWnd::OnInitMenuPopup(CMenu* pMenu, UINT nIndex, BOOL bSysMenu)
to see how its done there any in effect mirror the code yourself.
If you vote me down, my score will only get lower
|
|
|
|
|
Between calls to GetSubMenu() and TrackPopupMenu() , you should be able to use CheckMenuItem() .
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
Yeah it's fine setting the check state, but I'd like to do it through the normal cmd UI mechanism. Much more elegant!
Joel Holdsworth
|
|
|
|
|
Joel Holdsworth wrote:
Much more elegant!
Agreed. Here's how I did it:
BEGIN_MESSAGE_MAP(CMyView, CListView)
ON_NOTIFY_REFLECT(NM_RCLICK, OnRclick)
ON_UPDATE_COMMAND_UI(ID_ITEM_DELETE, OnUpdateItemDelete)
END_MESSAGE_MAP()
void CMyView::OnRclick(LPNMHDR, LRESULT* pResult)
{
CListCtrl &ctrlList = GetListCtrl();
CPoint pt;
CMenu menu,
*pSubMenu;
if (ctrlList.GetNextItem(-1, LVIS_SELECTED) != -1)
{
menu.LoadMenu(IDR_ITEM_MENU);
pSubMenu = menu.GetSubMenu(0);
pt = GetMessagePos();
pSubMenu->TrackPopupMenu(TPM_LEFTALIGN, pt.x, pt.y, this);
}
*pResult = 0;
}
void CMyView::OnUpdateItemDelete(CCmdUI* pCmdUI)
{
CListCtrl &ctrlList = GetListCtrl();
pCmdUI->Enable(ctrlList.GetNextItem(-1, LVIS_SELECTED) != -1);
} Now the Delete item in the main menu, the toolbar button, and the context menu is enabled/disabled correctly.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
Hmm, that interesting. I'm basically doing the exact same thing, but it's not working. Maybe it's because your class is derrived from CView rather than CWnd, so MFC has added some voodoo magic. I'm not sure.
Joel Holdsworth
|
|
|
|
|
Aha.... Solved it. Just a case of tweaking the standard message routing a little:
BEGIN_MESSAGE_MAP(CLiveView, CWnd)
...
ON_MESSAGE(WM_INITMENUPOPUP, OnInitMenuPopup)
END_MESSAGE_MAP()
LRESULT CLiveView::OnInitMenuPopup( WPARAM wparam, LPARAM lparam )
{
return AfxGetMainWnd()->SendMessage(WM_INITMENUPOPUP, wparam, lparam);
} Thanks for your help.
Joel Holdsworth
|
|
|
|
|
char *a[5];
Above line allows me to enter 5 strings like *(a+1) etc.
thats fine when # of do not change.
How can i do it dynamically, ie. user enters the # of strings to be entered.
char *a;
a = new char[5];
above one only allocates 5 characters and not 5 strings
Please help thanx.
|
|
|
|
|
Just use char ** a to represent a "pointer to pointer to char." You can then allocate 5 strings of length 10 characters as follows:
a = new char ** [5];
for(int Index = 0; Index < 5; Index++)
{
a[Index] = new char [10];
}
Bob Ciora
|
|
|
|
|
Bob Ciora wrote:
a = new char ** [5]; // should be checked for NULL
It should be that instead:
a = new char * [5]; // should be checked for NULL
|
|
|
|
|
char (*a)[5];
a=(char**)new char;
-- modified at 1:48 Monday 29th August, 2005
|
|
|
|
|
#include "stdafx.h"
#include <iostream.h>
int main(int argc, char* argv[])
{
int NumOfStr = 0, StringLength = 10;
//get number of strings from the user
cout << "Enter number of strings: ";
cin >> NumOfStr;
char **a;
a = new char * [NumOfStr];
for(int Index = 0; Index < NumOfStr; Index++)
{
a[Index] = new char [StringLength];
sprintf(a[Index], "string #%d", Index);
}
//clean-up the memory
for(Index = 0; Index < NumOfStr; Index++)
{
delete [] a[Index];
}
delete [] a;
return 0;
}
|
|
|
|
|
Hello,
I have a class CStaticEx, which is derived from CStatic and the text is drawn in the OnPaint() of CStaticEx.
I use SetDialogBkColor(...) to change the background and text color of the dialogs in my program.
But the text drawn in OnPaint of CStaticEx is black.
Is there any function to get the dialog background and text colors?
Thanks in advance.
-- modified at 6:36 Friday 26th August, 2005
|
|
|
|
|
GetSysColor(COLOR_3DFACE) should give you the dialog color.
GetSysColor(COLOR_WINDOWTEXT) should give you the right text color.
He is smart. He will make our Windows go.
|
|
|
|
|
Hello.,
I used CMonthCalCtrl to getting Selected Date.
But Date field is getting error .
Plz suggest me.,
*****How to get User selected date using CMonthCalCtrl
Plz Give the complete code.
Praveen Chowdam Kumar
|
|
|
|
|
if m_Cal is your control
COleDateTime odt;
m_Cal.GetCurSel(odt);
~RaGE();
|
|
|
|
|
parims wrote:
But Date field is getting error .
And what would that error be?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|