|
I'm not even sure where to begin, I highlighted in red the section where I believe it blows up....
#import "Tester.tlb"
using namespace Tester;
class CTestDlg : public CDialog
{
DECLARE_DYNAMIC(CTestDlg);
friend class CTestDlgAutoProxy;
public:
CTestDlg(CWnd* pParent = NULL);
Tester::_Numbers *com_ptr ;
CoInitialize(NULL);
<font color="red">Tester::_NumbersPtr p(__uuidof(Tester::_Numbers));</font>
com_ptr = p;
long i = com_ptr->GetDay();
The message that pops up says: "Runtime Error! The application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information." Where does and error message like that come from?
Nick Parker
You see the Standards change. - Fellow co-worker
|
|
|
|
|
Try:
Tester::_NumbersPtr p;
p.CreateInstance(__uuidof(Tester::_Numbers));
Dave
|
|
|
|
|
Nick Parker wrote:
Tester::_NumbersPtr p(__uuidof(Tester::_Numbers));
Should be
Tester::_NumbersPtr p(__uuidof(Tester::Numbers));
The constructor always takes the CLSID of the class not IID of the interface.
The mistakes made in this API make me realise that Microsoft has become big enough that it can shelter morons. If anyone working for me wrote anything this bad and tried to release it, I would kill them and display the body as a warning to the rest of the team. - Christian Graus about C# - GDI+
|
|
|
|
|
Rama Krishna wrote:
Should be
Tester::_NumbersPtr p(__uuidof(Tester::Numbers));
I tried this and it looks like this now:
CoInitialize(NULL);
Tester::_NumbersPtr p(__uuidof(Tester::Numbers));
com_ptr = p;
long i = com_ptr->GetDay();
AfxMessageBox(i);
However it throws an error in appui1.cpp . What file is this, I have never heard of it.
Nick Parker
You see the Standards change. - Fellow co-worker
|
|
|
|
|
>>AfxMessageBox(i);
AfxMessageBox takes the ID of the string resource not a number. So you need to wrote code like :-
long i = com_ptr->GetDay();
char sz[32];
itoa(i, sz, 10);
AfxMessageBox(sz);
The mistakes made in this API make me realise that Microsoft has become big enough that it can shelter morons. If anyone working for me wrote anything this bad and tried to release it, I would kill them and display the body as a warning to the rest of the team. - Christian Graus about C# - GDI+
|
|
|
|
|
How to get the free video memory?
|
|
|
|
|
Take a look on the DirectDraw / DirectX SDK!
Daniel
---------------------------
Never change a running system!
|
|
|
|
|
Thanks Daniel.
But, I'm using Win32 and DirectX 8.1 SDK.
DX API GetAvailableTextureMem() returns an estimate of the amount of available texture memory.
I want to know the actual size of the video RAM of installed graphic card.
|
|
|
|
|
Take a look on the IDirectDraw7::GetAvailableVidMem function.
IDirectDraw7::GetAvailableVidMem:
The IDirectDraw7::GetAvailableVidMem method retrieves the total amount of display memory available and the amount of display memory currently free for a given type of surface.
Daniel
---------------------------
Never change a running system!
|
|
|
|
|
Thanks Daniel^^;;
(Why is this omitted in DirectX 8?)
|
|
|
|
|
John Seo wrote:
Why is this omitted in DirectX 8?
I doun't know ! Ask Bill !
Daniel
---------------------------
Never change a running system!
|
|
|
|
|
Hi :
I need some help. What I am trying to do is to have a common dialog that can be used from any class, a good example would be a file browser or print dialog.
Suppose I create the dialog template ( through resource editor ) , and the wizard creates a class Dlg.cpp and Dlg.h.
I have a derived button class ( call XButton ) that if double clicked, should open up this dialog. Naturally, I have to include Dlg.h - but it gives me the following errors :
c:\windows\desktop\vc++\x\mynewdlg.h(21) : error C2065: 'IDD_DIALOG123' : undeclared identifier
c:\windows\desktop\vc++\x\mynewdlg.h(21) : error C2057:
It seems that I can only include this Dlg.h to files that source in resource.h - which well, makes sense since IDD_DIALG123 is defined in there.
How do I work around this ?
Any suggestion will be appreciated.
|
|
|
|
|
hi,
i had a similar problem previously, I guss in your resource.h you don't have your dialog id and a value assigned to it. If it does then is your classwizard using the dialog for yourdlg.h and .cpp files. If yes then do one thing note the number from the resource.h file for your dialog and write it into the place IDD_DIALOG123 in enum { IDD = IDD_DIALOG123 }.
hope it solves ypur problem.
cheers,
Himanshu
|
|
|
|
|
Thanks. I know what you mean. Your answer works, but I need a bit more.
I also tried including resource.h and the file compiled fine.
What I really need is this :
This dialog box will eventually need to go into a library, and be available at various parts of the program. I have been reading up a fair bit since I sent this mail, and realised that to create a CDialog class, I need the resource id. Problem I see here is that library allows me to include *.cpp and *.h to build the *.lib, but not the resource.h
file.
How does the common dialogs like CFileDialog work, since it is derived from CDialog->CCommonDialog too ?
Perhaps, what I need is done differently, and I am going the wrong way.
Any suggestion to put me back to the correct path is very much appreciated.
Thanks.
|
|
|
|
|
Hi,
I have a dialog that has to lauch some quite big operation and I want the user to be able to hit the Cancel button to stop the execution of the operation.
I was using a thread:
m_hThread = (HANDLE)_beginthreadex( NULL, 0, &ApplyProc, this, 0, &threadID );
where this is a pointer to my dialog. I was doing this because there where too many objects I needed so I tought it would be easier to just pass a pointer to the dialog.
In the thread function, I would cast a pointer to the dialog and use functions from it:
CDlgWizard* pD = (CDlgWizard*)pDlg;
pD->SomeFunction();
…
…
Now, this works fine on some machines, but on some other, it would make the app crash!
I guess I need to learn how to use threads
How can I acheive this? Is there any other was than using threads? As long as the user can cancel the operation, it's fine with me!
Also, I'm using ATL but I guess it doesn't really matter for that kind of problem.
Thanks!
|
|
|
|
|
|
ok so i got this dialog application. at the beggining , before the main dialog shows, i wanted to show a splash dialog.
basically , im unsure how to do this.. the code below is what I have started in the Applications initinstance()....
I dont know how to programmatically exit out of the DoModal state so i can continue on to sleep statement, and then to close dialog.... please help thanks.
// show splash window
CSplashy splash;
splash.DoModal();
Sleep(5000); // sleep roughly 5 seconds..
// Need to kill splash dialog here and continue program....
CEyeSpyDlg dlg;
m_pMainWnd = &dlg;
int nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}
// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;
todo....
:: insert inpirational text here ::
|
|
|
|
|
You can't use a modal dialog as splashscreen unless you start messing with a timer within the splashscreen dialog.
"You can stand all night at a redlight anywhere in town, hailing Marys left and right but none of them slow down. I've seen the best of men go past. I don't wanna be the last..."
|
|
|
|
|
Hi,
Hope someone can help me out here.
I'm trying to add a tracking tooltip to my app, so I got the required code from the vS help files and then added it to my code. So basically I have:
<br />
HWND WINAPI CreateTT(HWND hwndOwner)<br />
{<br />
<br />
<br />
}<br />
in my wndproc I added
<br />
case WM_MOUSEMOVE:<br />
<br />
if(g_bIsVisible){<br />
<br />
#define X_OFFSET 15<br />
#define Y_OFFSET X_OFFSET<br />
GetCursorPos(&point);<br />
SendMessage(g_hwndTT,<br />
TTM_TRACKPOSITION,<br />
0,<br />
(LPARAM)MAKELPARAM(point.x + X_OFFSET,<br />
point.y + Y_OFFSET));<br />
}<br />
return 0;<br />
I then added to my CASE WM_CREATE:
<br />
g_hwndTT = CreateTT(hwnd);<br />
When I compile my app I get a "Run-Time Check Failure #3 - The variable 'g_hwndTT' is being used without being defined." whenever I move the mouse. I don't understand why I get this error when I'm defining g_hwndTT using g_hwndTT = CreateTT(hwnd); I'm sure it is something simple I'm missing. Any help appreciated,
Thanks in advance,
Paddy.
|
|
|
|
|
When an MFC application starts up does it intentionally set the "current direcotry" to its folder? I'm trying to load a file into the app when it's type is opened through Explorer, I've disable it from complaining about it not find the file (CCommandLineInfo::m_strFilename doesn't like spaces . When it loads the file..even though its not the one opening (doc class). How can I prevent it from changing the directory it throws all of the CFile file openings off (even though all of them use the full directory path).
-Steven
CP Addict
By reading this message you are held fully responsible for any of the mispelln's or grammer, issues, found on, codeproject.com.
For those who were wondering, actual (Linux) Penguins were harmed in creating this message.
|
|
|
|
|
Once again I have gotten bitten by VC++ treating the "bool" type as the rough equivilant of "void". Given the following two member functions (simplified slightly):
::Parse(LPCTSTR pStr, TCHAR delimeter, bool append = false);<br />
::Parse(LPCTSTR pStr, bool append = false);
When I use xxx.Parse(str, ',');
VC++ declared they are ambiguous. On whose planet?
I seriously want a switch that makes a bool type accept only true , false or the result of a comparison operation.
Having ranted all that, what does the C++ standard say about bool ? Is it the empty type VC++ uses or a strict type?
|
|
|
|
|
bool is an proper type and can be used to overload functions the way you want.
Looks like Microsoft is wrong. Again.
he he he. I like it in the kitchen! - Marc Clifton (on taking the heat when being flamed)
Awasu v0.4a[^]: A free RSS reader with support for Code Project.
|
|
|
|
|
Are you sure you're not doing a Unicode build?
the thingies above resove fine (for me) when TCHAR is actually a char.
However, when TCHAR resolves to unsigned short, it's of course ambigous (should it expand to 16 bit, or reduce to one?)
Those who not hear the music think the dancers are mad. [sighist] [Agile Programming]
|
|
|
|
|
Joe Woodbury wrote:
Once again I have gotten bitten by VC++ treating the "bool" type as the rough equivilant of "void".
That is not entirely correct I believe, and depending on what TCHAR expands to it might actually be that the VC compiler (even that you don't state version) might actually be correct.
If you are compiling the displayed code as Unicode, meaning TCHAR expands to either the C++ required type wchar_t, or the MS invented undigned short (this depends upon both compiler version and compiler flags!), there would be an equally bad match for both bool and unsigned char for the char literal ','.
|
|
|
|
|
I've identified the problem.
Since the character is not defined as a wchar_t (either with L or _T), in UNICODE mode, it is still a char . The compiler must then fit the plain char with the "best" match, but [in my tests] never considers wchar_t if there is an alternate available. It will even pick int over wchar_t .
In my opinion, bool should never be selected. Even if there were only one function with a bool argument, I want an error to be generated. (For example, given void function(bool isValid); , function(1) should generate an error.)
char should pick wchar_t before to int , or at least a switch should be available to force this behavior.
|
|
|
|