|
Viorel. wrote: Are you sure this function is executed when you start the program, open the dialog and click on menu item?
Yes! The function IS executed. I put a message box and checked for both. .Thats the terriple part. I added the code to make the grid appear/disappear. Every thing is working fine. Only the check is not appearing.
Fortitudine Vincimus!
|
|
|
|
|
TheinstruTara wrote: added the code to make the grid appear/disappear. Every thing is working fine. Only the check is not appearing.
but the code you would use to make the grid appear/disappear would be in
void COption2::OnChartoptionsGrid()
setting the check mark is supposed to be happening in
void COption2::OnUpdateChartoptionsGrid(CCmdUI* pCmdUI)
There is no default support for calling OnUpdate routines in dialog boxes, there are articles etc... on how to do it.
If you set a breakpoint on the line
pCmdUI->SetCheck(IsGrid);
do you break in to the debugger when your dialog loads?
cje
|
|
|
|
|
Yes. I does.
Fortitudine Vincimus!
|
|
|
|
|
then I guess that my only other suggestion would be to get a pointer to the CMenu object and call CheckMenuItem directly instead of going through the OnUpdate mechanism. Something is certainly strange here - my code uses pCmdUI->SetCheck without a problem. sorry I can't be more help
cje
|
|
|
|
|
then I guess that my only other suggestion would be to get a pointer to the CMenu object and call CheckMenuItem direclty instead of going through the OnUpdate mechanism. My code uses pCmdUI->SetCheck without problems so there is definately something not right going on. Sorry I can't be of more help
cje
|
|
|
|
|
Oh no. So MY VS wants to trouble me
Thanks a lot for the help, all the same.
Fortitudine Vincimus!
|
|
|
|
|
I just got an email requesting me to write code for you to help troubleshoot this (I do not see the item yet on the message board). I think the request is a little over the top and my answer is no, I will not write a dialog box based application with a menu showing a working version of SetCheck.
I did, however do a quick google search for "CDialog CMenu" and in less than 5 minutes found others with the same problem that have been helped and a link to a microsoft article explaining a possible solution
http://support.microsoft.com/default.aspx?scid=kb;en-us;242577[^]
did you do any research on this or are you just wanting other people to do your work?
cje
|
|
|
|
|
cje wrote: (I do not see the item yet on the message board).
You did not see it on the message board because I did email my request to you.
cje wrote: did you do any research on this or are you just wanting other people to do your work?
Oh no. Please dont mistake me. I have struggled with this since two days and only then did I come to codeproject. Because I was'nt getting any errors and debuging showed that the everything is fine I did not know what to do.
My VS does behave unusually sometimes. I have to repetedly delete the debug files and the .ncb files to make things work. I had tried all that but in vain.
Anyway, NOW I know. Thanks a billion for the help. Next time, I shall google first!
Fortitudine Vincimus!
|
|
|
|
|
I checked the IsGrid number too. It toggles propery between 0 and 1.
Fortitudine Vincimus!
|
|
|
|
|
Is there anyother way of doing it?
Fortitudine Vincimus!
|
|
|
|
|
Hai
Is there any way in vc++ to round a double value to two(for example) decimal places without using any string function i.e I need the rounded value as a double value but not as a string.
Thanks in advance.
Taruni
|
|
|
|
|
Would something like this suffice?
double d = 12.3456;
int n = d * 1000.0;
double r = (n + 5) / 1000.0;
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
double round(double x, unsigned short places)
{
double multiplier = pow(10, (double)places);
double x1 = x * multiplier;
long y = (long)x1;
return (double)y / multiplier;
}
This method will truncate the last decimal place instead of rounding it. That is, if you have 1.246, it will be rounded to 1.24 instead of 1.25.
There are also some methods in the standard library for setting the precision of doubles, floats, etc. You might want to check those out as well.
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
First you have to decide how you want them rounded:
Round up:
-1.5 -> -1.0
+1.5 -> +2.0
Round down:
-1.5 -> -2.0
+1.5 -> +1.0
Round towards 0:
-1.5 -> -1.0
+1.5 -> +1.0
'Bankers' rounding (round to even):
1.45 -> 1.4 (rounded down)
1.55 -> 1.6 (rounded up)
idea being that some will round up, some down, evens out in the end
...
...cmk
Save the whales - collect the whole set
|
|
|
|
|
Hi,
My project need use a exe(statically linked MFC) load a dll(statically linked MFC),
and create a CDHtmlDialog in the dll.
I add a CDHtmlDialog to the DLL, "class DHtmlDialogTest : public CDHtmlDialog"
and create dialog at DLL's export function,
"DHtmlDialogTest.Create(IDD_DHtmlDialogTest , CWnd::GetDesktopWindow());"
But when excute DHtmlDialogTest.Create(IDD_DHtmlDialogTest , CWnd::GetDesktopWindow());
then it'll enter "dlgdhtml.cpp"'s function "CDHtmlDialog::OnInitDialog()"
at following code inside "CDHtmlDialog::OnInitDialog()"
--------------------------------------------------------------------------
if (m_pBrowserApp == NULL)
{
// create the control window
m_wndBrowser.CreateControl(CLSID_WebBrowser, NULL,
WS_VISIBLE | WS_CHILD, rectClient, this, AFX_IDC_BROWSER);
lpUnk = m_wndBrowser.GetControlUnknown();
if (FAILED(lpUnk->QueryInterface(IID_IWebBrowser2, (void**) &m_pBrowserApp)))
{
m_wndBrowser.DestroyWindow();
DestroyWindow();
return TRUE;
}
}
--------------------------------------------------------------------------
it will GPF which is get a unhandle exception when excute
if (FAILED(lpUnk->QueryInterface(IID_IWebBrowser2, (void**) &m_pBrowserApp)))
the m_wndBrowser is NULL and lpUnk is also NULL.
and,
1. I can create a CDialog in the same DLL above, only can't create a CDHtmlDialog.
2. If use a exe(dynamically link MFC) load a dll(Extension DLL use MFC),
it have no problem,
it can do the same thing, create a CDHtmlDialog in the dll perfectly.
Maybe because I can't load the resource?
Because I trce the call stack, when enter afxwin2.inl excute following code:
CDialog::Create(ATL_MAKEINTRESOURCE(nIDTemplate), pParentWnd);
ATL_MAKEINTRESOURCE(nIDTemplate) return a bad ptr,
Or is there any thing I need to be careful when use a exe(statically linked MFC) load a dll(statically linked MFC),
and create a CDHtmlDialog in the dll?
Thanks for your help~
-- modified at 3:02 Friday 30th June, 2006
|
|
|
|
|
Since the dialog is based on WebBrowser ActiveX control, I suppose you should enable ActiveX controls using this initialization function:
<pre><code>AfxEnableControlContainer();</code>
Put it in InitInstance handler of your CWinApp class in DLL.
Maybe some other initialization functions are required too.
I hope it helps.
|
|
|
|
|
Hi, Viorel,
After I tried put AfxEnableControlContainer();
it still GPF at same line.
Ryan
|
|
|
|
|
I know how to solve it,
use ::OleInitialize(NULL);
Thanks
|
|
|
|
|
I have the following problem:
I have a dll compiled with MinGW and a header file that describes the DLL exports. I want to use this DLL in a Visual C++ projects. Since i don't have a LIB file and i don't want to use LoadLibrary function i created a DEF file. The contents of the EXPORTS section of the DEF file i toke from DUMPBIN /EXPORTS [the_dll], so it should be ok.
After i created the lib file i included it in my Visual C++ project and the project has compiled successfully. But when i executed it, the application crashed. This application is working when compiled with GCC and the same DLL.
So is the problem somewhere in MinGW or what?
May be i must pass some special parameters to cl.exe or link.exe
Experts please help!
|
|
|
|
|
This has probably nothing to do with the fact that it's a dll. Start your debugger to see where the program crashes.
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
Ok i will explain in more details:
So in the header file i have a definition of an abstract class wich has onlu pure virtual methods.
In the DLL i have only one export function which is returning a pointer to an instance of this class or more precisely some class that inherits this abstract class.
The program is something like:
<br />
SomeClass* c = ImportedMethod();<br />
c->someMethod(); <br />
It looke strange i know, the problem is that i don't hava the source of the DLL neither i have any more information about it. Only those header:
<br />
class SomeClass <br />
{<br />
public:<br />
virtual void someMethod() = 0;<br />
}<br />
extern "C"<br />
__declspec (dllexport) SomeClass * ImportedMethod();<br />
|
|
|
|
|
What is the value of c ? Does it point to a valid memory address ?
Otherwise your method could simply return NULL and you didn't check it.
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
c isn't null. c contains a valid memory address and according to the Visual Studio debugger it contains the addresses of virtual functions.
The same source is working when compiled with GCC.
The difference may be is in the calling conventions or i don't know.
But there is no problem in the source.
The problem is in the dll that is used i think.
|
|
|
|
|
Hey guys
I was wondering why you use
typedef Handle ****Handle;
What does it exactly do??
I'm sorry guys, I didn't mean *** to be a pointer rather a dummyname
typedef Handle ObjectHandle
This is what I meant
-- modified at 11:10 Thursday 29th June, 2006
|
|
|
|
|
It's a pointer to a pointer to a pointer to a pointer to a Handle
are you certain that's the way it is written ? because typedefing with the name name should not work.
In what context is it used ?
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|