|
The main class is
class CCryptoCtxApp : public CWinApp
but the class which should display the dialog is
<br />
class ATL_NO_VTABLE CCryptoShlExt : <br />
public CComObjectRootEx<CComSingleThreadModel>,<br />
public CComCoClass<CCryptoShlExt, &CLSID_CryptoShlExt>,<br />
public IDispatchImpl<ICryptoShlExt, &IID_ICryptoShlExt, &LIBID_CRYPTOCTXLib>,<br />
public IShellExtInit,<br />
public IContextMenu<br />
|
|
|
|
|
And what is the return value from DoModal()? DoModal() usually fails, when it cannot locate resources for dialog.
|
|
|
|
|
DoModal() returns IDCANCEL.
|
|
|
|
|
Problem is, that MFC works well within MFC application. Your shell extension is running under explorer.exe and that's not MFC application. DoModal() function can fail for two reasons - cannot locate resources or it is not happy with your main window - explorer window. I had similar problem and I finished with writing my own DoModal() function. I can send it to you this evening, if you want. Try to debug DoModal(), to find out, where it fails.
|
|
|
|
|
No, i will not try to debug it anymore. I tried it about 2 hours. Enough now
Perhaps i create a new MFC DLL containing the dialog.... i need the MFC functions in my program. But you may send me your DoModal() version.
thanks for your help
-Dominik
|
|
|
|
|
This is my class, which should help you. It uses my CSeException class from this site. Note, you must pass handle of your main window to DoModal() function.
class CDominikDlg : public CDialog
{
// Construction
public:
CDominikDlg(DWORD dwID, CWnd* pParent = NULL); // standard constructor
// Dialog Data
//{{AFX_DATA(CDominikDlg)
//}}AFX_DATA
MSG m_msgCur;
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CDominikDlg)
public:
virtual int DoModal(HWND hWndParent);
virtual int RunModalLoop(DWORD dwFlags = 0);
virtual BOOL PumpMessage(void);
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
CFont m_font;
// Generated message map functions
//{{AFX_MSG(CDominikDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
#define WM_KICKIDLE 0x036A // (params unused) causes idles to kick in
CDominikDlg::CDominikDlg(DWORD dwID,CWnd* pParent /*=NULL*/)
: CDialog(dwID, pParent)
{
//{{AFX_DATA_INIT(CDominikDlg)
//}}AFX_DATA_INIT
m_font.CreateFont(8, 6, 0, 0, FW_THIN, 0, 0, 0, DEFAULT_CHARSET,
OUT_CHARACTER_PRECIS, CLIP_CHARACTER_PRECIS, DEFAULT_QUALITY,
DEFAULT_PITCH | FF_DONTCARE, _T("Courier New"));
}
void CDominikDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDominikDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDominikDlg, CDialog)
//{{AFX_MSG_MAP(CDominikDlg)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDominikDlg message handlers
int CDominikDlg::DoModal(HWND hWndParent)
{
// can be constructed with a resource template or InitModalIndirect
ASSERT(m_lpszTemplateName != NULL || m_hDialogTemplate != NULL ||
m_lpDialogTemplate != NULL);
// load resource as necessary
LPCDLGTEMPLATE lpDialogTemplate = m_lpDialogTemplate;
HGLOBAL hDialogTemplate = m_hDialogTemplate;
HINSTANCE hInst = g_hDll;
HINSTANCE hinTmp = afxCurrentInstanceHandle;
HINSTANCE hresTmp = afxCurrentResourceHandle;
afxCurrentResourceHandle = g_hDll;
afxCurrentInstanceHandle = g_hDll;
if (m_lpszTemplateName != NULL) {
HRSRC hResource = ::FindResourceEx(g_hDll,RT_DIALOG,m_lpszTemplateName,MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL));
hDialogTemplate = LoadResource(hInst, hResource);
}
if (hDialogTemplate != NULL)
lpDialogTemplate = (LPCDLGTEMPLATE)LockResource(hDialogTemplate);
// return -1 in case of failure to load the dialog template resource
if (lpDialogTemplate == NULL)
return -1;
// disable parent (before creating dialog)
//HWND hWndParent = PreModal();
//AfxUnhookWindowCreate();
BOOL bEnableParent = FALSE;
if (hWndParent != NULL && ::IsWindowEnabled(hWndParent)) {
::EnableWindow(hWndParent, FALSE);
bEnableParent = TRUE;
}
try {
// create modeless dialog
//AfxHookWindowCreate(this);
if (CreateDlgIndirect(lpDialogTemplate,
CWnd::FromHandle(hWndParent), hInst)) {
if (m_nFlags & WF_CONTINUEMODAL) {
// enter modal loop
DWORD dwFlags = MLF_SHOWONIDLE;
if (GetStyle() & DS_NOIDLEMSG)
dwFlags |= MLF_NOIDLEMSG;
VERIFY(RunModalLoop(dwFlags) == m_nModalResult);
}
// hide the window before enabling the parent, etc.
if (m_hWnd != NULL)
SetWindowPos(NULL, 0, 0, 0, 0, SWP_HIDEWINDOW|
SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|SWP_NOZORDER);
}
} catch(CSeException *e) {
DUMPEXCEPTION(e);
::SetLastError((unsigned long)NTE_FAIL);
e->Delete();
} catch (...) {
TRACE(_T("%s(%d): Unknown exception.\n"),__FILE__,__LINE__);
m_nModalResult = -1;
}
if (bEnableParent)
::EnableWindow(hWndParent, TRUE);
if (hWndParent != NULL && ::GetActiveWindow() == m_hWnd)
::SetActiveWindow(hWndParent);
// destroy modal window
DestroyWindow();
PostModal();
// unlock/free resources as necessary
if (m_lpszTemplateName != NULL || m_hDialogTemplate != NULL)
UnlockResource(hDialogTemplate);
if (m_lpszTemplateName != NULL)
FreeResource(hDialogTemplate);
afxCurrentInstanceHandle = hinTmp;
afxCurrentResourceHandle = hresTmp;
return m_nModalResult;
}
int CDominikDlg::RunModalLoop(DWORD dwFlags)
{
ASSERT(::IsWindow(m_hWnd)); // window must be created
ASSERT(!(m_nFlags & WF_MODALLOOP)); // window must not already be in modal state
// for tracking the idle time state
BOOL bIdle = TRUE;
LONG lIdleCount = 0;
BOOL bShowIdle = (dwFlags & MLF_SHOWONIDLE) && !(GetStyle() & WS_VISIBLE);
HWND hWndParent = ::GetParent(m_hWnd);
m_nFlags |= (WF_MODALLOOP|WF_CONTINUEMODAL);
MSG* pMsg = &m_msgCur;
// acquire and dispatch messages until the modal state is done
for (;;) {
ASSERT(ContinueModal());
// phase1: check to see if we can do idle work
while (bIdle &&
!::PeekMessage(pMsg, NULL, NULL, NULL, PM_NOREMOVE)) {
ASSERT(ContinueModal());
// show the dialog when the message queue goes idle
if (bShowIdle) {
ShowWindow(SW_SHOWNORMAL);
UpdateWindow();
bShowIdle = FALSE;
}
// call OnIdle while in bIdle state
if (!(dwFlags & MLF_NOIDLEMSG) && hWndParent != NULL && lIdleCount == 0) {
// send WM_ENTERIDLE to the parent
::SendMessage(hWndParent, WM_ENTERIDLE, MSGF_DIALOGBOX, (LPARAM)m_hWnd);
}
if ((dwFlags & MLF_NOKICKIDLE) ||
!SendMessage(WM_KICKIDLE, MSGF_DIALOGBOX, lIdleCount++)) {
// stop idle processing next time
bIdle = FALSE;
}
}
// phase2: pump messages while available
do {
ASSERT(ContinueModal());
// pump message, but quit on WM_QUIT
if (!PumpMessage()) {
AfxPostQuitMessage(0);
return -1;
}
// show the window when certain special messages rec'd
if (bShowIdle &&
(pMsg->message == 0x118 || pMsg->message == WM_SYSKEYDOWN)) {
ShowWindow(SW_SHOWNORMAL);
UpdateWindow();
bShowIdle = FALSE;
}
if (!ContinueModal())
goto ExitModal;
} while (::PeekMessage(pMsg, NULL, NULL, NULL, PM_NOREMOVE));
}
ExitModal:
m_nFlags &= ~(WF_MODALLOOP|WF_CONTINUEMODAL);
return m_nModalResult;
}
BOOL CDominikDlg::PumpMessage()
{
ASSERT_VALID(this);
if (!::GetMessage(&m_msgCur, NULL, NULL, NULL)) {
return FALSE;
}
// process this message
if (m_msgCur.message != WM_KICKIDLE && !PreTranslateMessage(&m_msgCur)) {
::TranslateMessage(&m_msgCur);
::DispatchMessage(&m_msgCur);
}
return TRUE;
}
|
|
|
|
|
Hi there ,
I have a class lets say CMyClass, it contains a member variable of type CArray of lets say int.
Now I have a public function of this Class GetValue(int nIndex) now this function returns the Reference of int which is actually a reference to a particular index of my CArray type member variable.
Now here is the problem .. My GetValue function performs some checks before returning the Refrence . now in case the checks fails I dont want to return the reference .. in that case WHAT DO I RETUNR FROM MY CODE.
does any body understand what I am trying to ask ?
Abhishek Narula
"Learn to appreciate others ... World would appreciate you"
|
|
|
|
|
Throw an exception. There's no reference equivalent of a NULL pointer, so you must either return a valid reference or throw.
|
|
|
|
|
Wonderfull Idea !! thanks .. please tell me more about throwing exceptions also ..
Abhishek Narula
"Learn to appreciate others ... World would appreciate you"
|
|
|
|
|
Throw an exception.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hmm that seems a better idea .. please throw some light on thoring exceptions also ..
Abhishek Narula
"Learn to appreciate others ... World would appreciate you"
|
|
|
|
|
Essentially, you just throw with throw , which interrupts the normal flow of execution and throws an object that can be catched by some point up the call stack with catch .
Just read your docs for throw and catch , and/or search some tutorial on the net, sure there're many out there.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
It goes like this:
1. Create a class CMyException. Here is an example:
class CMyException
{
CString strError;
public:
CMyException (CString& a) : strError (a) {}
void HandleError ()
{
AfxMessageBox (strError);
}
}
2. Do this in that function:
if (index_is_out_of_bounds)
throw CMyException ("Index out of bounds");
3. Catch the exception like this:
try
{
}
catch (CMyException& e)
{
e.HandleError ();
return;
}
You can also check MSDN for details or download a good C++ book. "Thinking in C++" from www.bruceeckel.com
Best regards,
Alexandru Savescu
|
|
|
|
|
Hi,
Can someone please tell me how can I set the size for a
CFormView, say if I want to set size to ( 1000, 1000 ).
Thanks,
Sansky
John 3:16
For God so loved the world,
that he gave his only begotten Son ( Jesus Christ ) ,
that whosoever believeth in him should not perish, but have everlasting life.
|
|
|
|
|
Use MoveWindow and then ResizeParentToFit .
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
In the view call SetScaleToFitSize()
Roger Allen
Sonork 100.10016
If I had a quote, it would be a very good one.
|
|
|
|
|
Hi,
I am trying to open a html file. for this i use DDE.
My DdeClientTransaction() call is as follows.
DdeClientTransaction( 0,
0,
hConv,
hItem,
CF_TEXT,
XTYP_REQUEST,
5000,
&dwResult )
It works fine, if the path for html file doesn't contain a space.
Could anyone knows how to make it work if the path contains a space in it?
Regards
Neha
|
|
|
|
|
|
I think that the first question that you should ask is who is the audience that you are developing your program for? I do not think that that interface looks so cluttered, so it may be a good one to follow. I guess the people at 3D Studio Max have had success with that interface so it probably would not hurt you to follow it.
One more thing to keep in mind, the more complicated that you make your interface the more advanced the user will need to be.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
It's kind of hard to read for old folks like me. Hopefully you'll use more contrast instead of black and dark gray.
BTW, on your sig, is the word "Wonders" correct or should it be "Wanders"? Wanders would make more sense to me.
|
|
|
|
|
Deal all,
In a dialog-based application, i have detect all the cd-rom devices
successfully. Now i want to insert and eject a cd-rom.
How to insert and eject a cd-rom by using sendAspi32Command ?
Thanks in advance!
chen
|
|
|
|
|
|
Hi,
I have a 24bit BMP and want to programatically convert
it to GIF file.
How do i do that
Sameer
|
|
|
|
|
Use any of the varios graphics libraries available on the net. For one, paintlib seems a good choice.
PS: Seems paintlib does not output GIFs, probably because of the patents problems associated with this format. If you can switch to PNG then the library will serve your needs.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Joaquín M López Muñoz wrote:
If you can switch to PNG then the library will serve your needs.
Actually, I have a 24 bit BMP and I want a format, which
converts it to a Browser Compatible format and its
size is the smallest.
Wha about the size of PNGs
Sameer
|
|
|
|
|