|
A .H file...
---------------------------------------------
#ifndef Some_H
#define Some_H
#import "Some.tlb" no_namespace, \
named_guids
#endif // Some_H
---------------------------------------------
and the Compiler is giving following stupid error...
---------------------------------------------
error C4772: #import referenced a type from a missing type library; '__missing_type__' used as a placeholder
---------------------------------------------
Helppppppppp!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! requested
mE
---------------------
A gasp of breath,
A sudden death:
The tale begun.
A rustled page
Passes an age:
The tale is done.
|
|
|
|
|
The type library you have referenced uses another type library that was not referenced with #import. This other .tlb file was not found by the compiler, so go and check it out.
"A robust program is resistant to errors -- it either works correctly, or it does not work at all; whereas a fault tolerant program must actually recover from errors."
|
|
|
|
|
I'm trying to exit my MFC application but from a different thread
The separate thread is started using timeSetEvent(), this separate timer is used to loop through received udp messages. When one of this messages tells me that the overall application(made os differennt exec) setup is wrong, I must exit.
when using PostMessage with WM_QUIT, I get a bunch of pointers which are null
Is there a better way to exit... or maybe I should not use the timeSetEvent() function?
|
|
|
|
|
A better way would be to signal your main thread, that some thing has gone wrong and terminate the application.
Are you using a CWnd->PostMessage or ::PostMessage( HWND ). You are not supposed to access any of the objects created by other threads, So use only ::PostMessage( HWND ).
"A robust program is resistant to errors -- it either works correctly, or it does not work at all; whereas a fault tolerant program must actually recover from errors."
|
|
|
|
|
A better way would be to signal your main thread that something has gone wrong and terminate the application using PostQuitMessage( ).
Are you using CWnd->PostMessage( ) or ::PostMessage( HWND ). You are not supposed to access objects created by other threads. So always use ::PostMessage( HWND ) from threads.
"A robust program is resistant to errors -- it either works correctly, or it does not work at all; whereas a fault tolerant program must actually recover from errors."
|
|
|
|
|
I actually tried both ways and none of them worked...
I used...
HWND _hwnd = AfxGetApp()->GetMainWnd()->m_hWnd;
PostMessage(_hwnd, WM_QUIT, a_ExitCode, 0);
I have tried with WM_CLOSE as well
|
|
|
|
|
AfxGetApp()->GetMainWnd()->m_hWnd
'AfxGetApp()->GetMainWnd()' this is where the bug resides. You are not supposed to access the Main window from your thread. You have to some how pass the HWND of the main window to the thread fn. Then you can use this HWND to send the ::PostMessage( HWND, WM_QUIT,..)
If you are using the AfxBeginThread fn, you can pass this parameter as LPVOID. Since you are using timeSetEvent, you can pass the HWND on DWORD_PTR parameter.
"A robust program is resistant to errors -- it either works correctly, or it does not work at all; whereas a fault tolerant program must actually recover from errors."
|
|
|
|
|
Okay, i have this problem with a screensaver i'm writing. Basically i want to write a screensaver that plays a video.
Then when the mouse is moved (or a key pressed) the program quits.
Everything works fine, except when the mouse is moved over the area of the video playing.
the following function doesnt get any "WM_MOUSEMOVE" callback while the mouse is over the video area
LRESULT WINAPI ScreenSaverProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam)
{
///////////////
my guess is that it might be a problem with the following
MCI_DGV_WINDOW_PARMS mciWindow;
mciWindow.dwCallback = 0L; //Here
mciWindow.hWnd = hWnd;
mciWindow.nCmdShow = SW_SHOW;
anyways, the
mciSendCommand(gwMCIDeviceID, MCI_PLAY, dwFlags, (DWORD)(LPMCI_DGV_PLAY_PARMS)&mciPlay);
function doesnt return any "WM_NOTIFY" call back or anything to the ScreenSaverProc
Any help with this would be greatly appriciated
|
|
|
|
|
I'm having problems with the CMemDC inside a CStatic derived class.
void MyStatic::OnPaint()<br />
{<br />
CPaintDC dc(this);<br />
CMemDC memDC(&dc);
<br />
CBrush brush(RGB(255,0,0));<br />
CPen pen(PS_SOLID,1,RGB(0,0,0));<br />
<br />
HBRUSH oldbrush=(HBRUSH)memDC->SelectObject(brush);<br />
HPEN oldpen=(HPEN)memDC->SelectObject(pen);<br />
<br />
memDC->Rectangle(&r);<br />
<br />
memDC->SelectObject(oldbrush);<br />
memDC->SelectObject(oldpen);<br />
}<br />
<br />
BOOL MyStatic::OnEraseBkgnd(CDC* pDC)<br />
{<br />
return TRUE;<br />
}
If I use this inside a derived CSliderCtrl, for example, a nice red box will be drawn with a black outline on a gray dialog. Top!
But inside a derived CStatic, the dialog is entirely white, nothing else. I've 2 different versions of CMemDC (both currently on codeproject), there's one that returns a white dialog, the other gives some random colors, like a corrupt bitmap.
What am I doing wrong here?
using: [VISUAL STUDIO 6.0 sp5] [WIN98/2]
|
|
|
|
|
hi,
why do you use CMemDC, and not directly dc ?
HBRUSH oldbrush=(HBRUSH)dc->SelectObject(brush);
HPEN oldpen=(HPEN)dc->SelectObject(pen);
dc->Rectangle(&r);
|
|
|
|
|
Double Buffering...
using: [VISUAL STUDIO 6.0 sp5] [WIN98/2]
|
|
|
|
|
Try this in OnDraw( CDC* dc ) like this
CMemDC pDC(dc);
if( !pDC->IsPrinting() )
{
}
"A robust program is resistant to errors -- it either works correctly, or it does not work at all; whereas a fault tolerant program must actually recover from errors."
|
|
|
|
|
I've changed it to a custom control derived from CWnd. Works fine now.
using: [VISUAL STUDIO 6.0 sp5] [WIN98/2]
|
|
|
|
|
* If you want to set the background color, you should have a look to this article: http://www.codeproject.com/miscctrl/colorcontols.asp?target=ccolorstatic[^]
On the use of MemDC:
* To avoid flickering, OnEraseBkgnd should return FALSE.
* you should use pointers with CDC::SelectObject
CBrush *pOldBrush = memDC->SelectObject(&brush);<br />
CPen *pOldPen = memDC->SelectObject(&pen);
...
memDC->SelectObject(pOldBrush);<br />
memDC->SelectObject(pOldPen);
Every gun that is made, every warship launched, every rocket fired, signifies in the final sense a theft from those who hunger and are not fed, those who are cold and are not clothed - Dwight D. Eisenhower
|
|
|
|
|
Hi all,
I am developing a dialog based application using VC 6.0
I have placed a RichText control on dialog template. Right clicking on it opens a control's properties window, in the Style's tab there is a combobox option Align Text. It has three values
- Right
- Centered
- Left
I have selected default value at design time, but I want to change this selection at runtime.
How can I accomplish this.
Thanks
The Phantom.
|
|
|
|
|
Have you looked at CRichEditCtrl::SetParaFormat() ?
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
How can we spy[hook] Registry Actions? such as RegSetValueEx that called in other running process.
thanks
|
|
|
|
|
|
If am searching for a way to exit a MFC MDI application if I discover an error in CMyView::OnInitialUpdate().
If I use SendMessage(WM_CLOSE) to the main window, I get some crashes in MFC classes.
Using exit(0) seems to be not very good, because of memeory leaks.
So what's the best way to end a MFC application during CMyView::OnInitialUpdate()?
Thanks in advance.
|
|
|
|
|
Use PostMessage instead of SendMessage. SendMessage is a synchronous do it now kind of thing, which will rip the floor from underneath you, while PostMessage will defer it until OnInitialUpdate returns.
Steve S
|
|
|
|
|
First iterate through all the open documents, and close them one by one. Then instead of using SendMessage to send WM_CLOSE, use PostMessage. It should work.
Acutually the program crashes, When OnActivateFrame( ... ) is invoked with WA_INACTIVE parameter and the 'this' pointer( which has an invalid value ). So use PostMessage.
"A robust program is resistant to errors -- it either works correctly, or it does not work at all; whereas a fault tolerant program must actually recover from errors."
|
|
|
|
|
Why not use PostQuitMessage() ?
Roger Allen
Sonork 100.10016
Were you different as a kid? Did you ever say "Ooohhh, shiny red" even once? - Paul Watson 11-February-2003
|
|
|
|
|
PostQuitMessage is another option. But it uses WM_QUIT instead of WM_CLOSE. I thought, since the guy was using WM_CLOSE, lets us point out, where he has went wrong. Actualy the problem was with using SendMessage, and not with WM_CLOSE.
"A robust program is resistant to errors -- it either works correctly, or it does not work at all; whereas a fault tolerant program must actually recover from errors."
|
|
|
|
|
I wonder what MFC is capable of?
Can it create full-screen 3D games?
Have anyone ever played games on
RealOne Arcade? Are they made from
MFC? Anyone knows what technology do
they use?
Thanks
|
|
|
|
|
Use Direct3D.
You can combine DX with MFC without any problems.
You can also use some 2D/3D library, but remember that it will run slower (software rendering).
using: [VISUAL STUDIO 6.0 sp5] [WIN98/2]
|
|
|
|