|
You can handle CMyDlg's messages in CMyClass by subclassing the CMyDlg instance after it's been created.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Thank you Ryan for you help.
Ryan Binns wrote: >subclassing the CMyDlg instance after it's been created.
subclassing the CMyDlg instance after it's been created. i have taken your post as follows:
1) The CMyDlg's instance is created in CMyApp, and there the dialog is DoModal()ed. So there in CMyApp im supposed to subclass it?
2)How to subclass an instance? can you be more specific with reference to my code at the link i posted in my previous post?
Best regards,
JT!
|
|
|
|
|
jusstujoo wrote: 1) The CMyDlg's instance is created in CMyApp, and there the dialog is DoModal()ed. So there in CMyApp im supposed to subclass it?
You'll have to do it after it's been created. In your WM_CREATE handler in your CMyDlg class would be a good place.
jusstujoo wrote: 2)How to subclass an instance? can you be more specific with reference to my code at the link i posted in my previous post?
You call SubclassWindow() on your dialog window. Have a look at the MSDN documentation to see exactly what you have to do. It's not too difficult.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Hello Ryan
Do you really think that i should do this SubclassWindow()?
Isint there means by which i can get msgs in CMyClass without writing anything in CMyDlg??
Well... let me try. Isint there a way that i can do CMyDlg-subclassing in CMyClass?
Thank you.
Best regards,
JT!
-- modified at 4:32 Wednesday 8th March, 2006
|
|
|
|
|
jusstujoo wrote: Isint there means by which i can get msgs in CMyClass without writing anything in CMyDlg??
Not easily. It is far, far harder without putting anything in CMyDlg. Yes, it's possible, but complex, difficult and, in my opinion, not worth the effort.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
MAN! i did log in. and wrote such a long message, when i clicked onto the PostMessage Button... it said you are not logged in as Jusstujoo, and when Backed it didnt even reloaded the text i wrote!!!
Ryan Binns wrote: not worth the effort
Well, i wanted to ask why it isnt a well earned hardwork? and why it is worthless?
Let me tell you wats exactly in my mind.
1) you must have(assuming you do), created and used an application that sends your app to systemtray and restores back when user clicks onto the systemtray icon associated with your app.
2) i want to do the same thing.
3) and to do that you need to put a notify-message in the message map and in the notifyicon structure. and then you get the WM_LButtonDown message when user clicks onto the systemtray icon. now im not asking how to put the app in systemtray and restore it back.
4) the problem is that how to get that notify-message in my Another class, the CMyClass, which is supposed to handle all the systemtray works?
5) what if i give you my that class, and all you need to do is to create an instance, passing "this" as an argument? and everything will be handled by CMyClass(the system tray class). Got it, now i guess it should be more clear?
Best regards,
JT!
|
|
|
|
|
jusstujoo wrote: the problem is that how to get that notify-message in my Another class, the CMyClass, which is supposed to handle all the systemtray works?
You can specify any window for your system tray callback. Just create an invisible window specifically for the other class - you don't need to worry about the dialog at all.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Ryan Binns wrote: You can specify any window for your system tray callback. Just create an invisible window specifically for the other class
you mean that:
1) i should create another dialog class.
2) and show it as SW_HIDE
3) and map the notify-message in CAnotherDlg class?
4) so, when the application icon on the systemtray will be click, it will send the notify message in CAnotherClass?
Is this correct?
Best regards,
JT!
|
|
|
|
|
jusstujoo wrote: i should create another dialog class.
I would just create another simple class derived directly from CWnd, no need to worry about a dialog. This is what I have done in the past:
class CTrayWnd : public CWnd
{
public:
CTrayWnd() { };
afx_msg LRESULT OnTrayIconMsg(WPARAM wParam, LPARAM lParam);
DECLARE_MESSAGE_MAP();
};
BEGIN_MESSAGE_MAP(CTrayWnd, CWnd)
ON_MESSAGE(TRAYICON_ICON_MESSAGE, OnTrayIconMsg)
END_MESSAGE_MAP()
LRESULT CTrayWnd::OnTrayIconMsg(WPARAM wParam, LPARAM lParam)
{
return 0;
}
...
m_pTrayWnd = new CTrayWnd;
m_pTrayWnd->CreateEx(0, AfxRegisterWndClass(0), "Tray Icon Window", 0, 0, 0, 0, 0, NULL, NULL, NULL); But yeah, that's the general idea. I just had this class at the top of one of my .cpp files - no header file is needed, it's only used in one place.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
I need to know how I can read the content in a pdf document using c++.
Allang Garder
|
|
|
|
|
|
which tool or switch work for it?
|
|
|
|
|
Just do a text search for "#define".
Steve
|
|
|
|
|
If you are using Visual studio then you can right click on that macro and select Goto Definition or Goto Declaration . This will take you to the file where it is defined.
Nibu thomas
Software Developer
|
|
|
|
|
I do not know what is the macro name. it could be define at .h file in cpp you can not easily to search.
|
|
|
|
|
I am using NtQueryDirectoryFile function to enumerate all files in a certain folder instead of FindFirstFile and FindNextFile. I just want to see their names so I use this structure
typedef struct _FILE_NAMES_INFORMATION {
ULONG NextEntryOffset;
ULONG Unknown;
ULONG FileNameLength;
WCHAR FileName[1];
} FILE_NAMES_INFORMATION, *PFILE_NAMES_INFORMATION;
how do I translate the "FileName" parameter to an multibyte char or a readble char.
I use WideCharToMultiByte(CP_ACP,0,n->FileName,n->FileNameLength,name,sizeof(name),NULL,NULL);
but the name is not totally translated but only the first 4 or 5 characters.
variable "name" being defined like this char *nume=(char *)malloc(n->FileNameLength);
Can someone please help me with this. it is verry urgent
thanks
gabby
-- modified at 21:20 Tuesday 7th March, 2006
|
|
|
|
|
Use W2A
Nibu thomas
Software Developer
|
|
|
|
|
I get thiese 3 errors
: error C2065: '_lpw' : undeclared identifier
'_convert' : undeclared dentifier
error C2065: '_acp' : undeclared dentifier
the headers i included (from what I ve read about w2a) are
AtlBase.h, AtlConv.h;
I am doing a win 32 aplication not mfc by the way
how should I not get the 3 errors ?
gabby
-- modified at 4:43 Wednesday 8th March, 2006
|
|
|
|
|
When using an ATL string conversion macro, specify the USES_CONVERSION macro at the beginning of your function in order to avoid compiler errors.
Nibu thomas
Software Developer
|
|
|
|
|
You have the right idea here - if you are going to be looping, you might want to stay away from the ATL conversion macros if you are using VC++ 6.0 - those macros dynamically allocate from the stack and you can quickly blow the stack if looping over a good amount of files.
euacela wrote: WideCharToMultiByte(CP_ACP,0,n->FileName,n->FileNameLength,name,sizeof(name),NULL,NULL);
If name is a pointer (and it looks like it is), you cannot use sizeof(...) on it to determine the size of what it points to. Try:
ULONG ulFNLen = n -> FileNameLength;
char *pcFileName = new char[ ulFNLen <code>+ 1</code> ];
::WideCharToMultiByte( CP_THREAD_ACP, WC_SEPCHARS, n -> FileName,
ulFNLen, pcFileName, ulFNLen, NULL, NULL );
pcFileName[ ulFNLen ] = '\0';
delete [] pcFileName; Your malloc(...) example is incorrect, because it does not include space for a terminating NUL character.
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
I have a workstation with AMD64 CPU's and 6 Giga Byte RAM ,OS is Windows XP 64 ,and installed Microsoft Platform SDK for Windows Server 2003 SP1.
My problem is:
1.I want to use MFC in vs2003 .net to develope my application,is it possible to use >3G RAM? the app is linked with /LARGEADDRESSAWARE, it can only use 2GB.
2.I use MFC in vs2005 .net, it can not do it too.how to use >3G RAM with VirtualAlloc(),can u help me ,or give me some sample code or detail link site(step by step).
2.there is no option in the vs2005 for AMD64 Platform in "configation
manager" ,why?
thank u very much!
-------
jht
jht
|
|
|
|
|
I have used CListCtrl to create a simple text list, with checkboxes.
What I need to do is to selectively disable an individual item on the list, so that it cannot be selected.
Is there a way through CListCtrl to deactivate an individual list entry? Perhaps by using the SetItemState or SetItemData operations?
Thanks.
|
|
|
|
|
humots wrote: Is there a way through CListCtrl to deactivate an individual list entry? Perhaps by using the SetItemState or SetItemData operations?
Yeah handle item selection event. Maintain an index of disabled entries. If item that is to be selected is a disabled one then de-select it. You can use SetItemState here.
Nibu thomas
Software Developer
|
|
|
|
|
Does anyone have any idea on how one can programmatically prevent another process terminating the process of "my application". I suspect that the terminator ( ) application is using TerminateProcess() and has a handle to the process of "my application" (since it usually creates it) and therefore has TERMINATE_PROCESS security privileges....
I realise that this is usually done for nerfarious reasons by malware/viruses etc but I have a sound business case for doing this (or at least delaying the process termination)
Phil Harding. myBlog [^] | mySite [^]
|
|
|
|
|
Phil Harding wrote: Does anyone have any idea on how one can programmatically prevent another process terminating the process of "my application"
No. If the user account associated with the other application has high enough privileges, it can terminate your application. AFAIK, There's nothing you can do about it. Your best bet is to ensure your application runs as the "Local System" user, but even then an admin will be able to kill it.
Incidentally, those other nefarious (I love that word ) programs don't prevent themselves being terminated, they detect when they are, and then restart themselves. The usually run two processes, and since only one can be terminated at a time by the user, the other one can detect that it has been killed, and restart it. You could take this path, if it only matters that an instance of your program is running. Of course, it won't help if you require the same instance of your program running and not be terminated.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|