|
Posting WM_CLOSE message to the main thread using PostThreadMessage doesn't close your application also. You have to post WM_CLOSE message to all windows on the main thread, as vikrams said. Here's the code how to do this :
BOOL CALLBACK EnumThreadWndProc(HWND hwnd, LPARAM lParam)
{
::PostMessage(hwnd,WM_CLOSE,0,0);
return TRUE;
}
EnumThreadWindows(rp[option-1].dwThreadId,EnumThreadWndProc,0); Regards,
Andrzej Markowski
|
|
|
|
|
I´m trying to use the IDirectDrawSurface::AlphaBlt method in wince.
Then I have to create an alpha surface and blit that surface to a "normal" (not an alpha surface) surface with the AlphaBlt method, I think....
But when I try to create an alpha surface,I get an invalid parameter as a result!
Is there anybody that has a clue to this error?
These are important flags for the DDPIXELFORMAT in wince:
DDPF_ALPHA: The pixel format describes an alpha-only surface.
DDPF_ALPHAPIXELS: The surface has alpha channel information in the pixel format.
DDPF_ALPHAPREMULT: The color components in the pixel are premultiplied by the alpha value in the pixel. If this flag is set, the DDPF_ALPHAPIXELS flag must also be set. If this flag is not set but the DDPF_ALPHAPIXELS flag is set, the color components in the pixel format are not premultiplied by alpha. In this case, the color components must be multiplied by the alpha value at the time that an alpha-blending operation is performed.
DDPF_RGB: The RGB data in the pixel format structure is valid.
I think I should only use the DDPF_ALPHA and DDPF_RGB flags but I am not sure?
Any comments?
I don´t think I should specify any alphabitdepth as there is no alpha channel information in the RGB_565 pixelformat,isn´t that right?
This is how the code looks like:
Globals:
<br />
LPDIRECTDRAW4 lpDD4;<br />
LPDIRECTDRAWSURFACE4 lpddsurf;<br />
SIZE size;<br />
<br />
size.cx=486;<br />
size.cy=274;<br />
<br />
CreateAlphaSurface(&lpddsurf,&size); <br />
<br />
int CreateAlphaSurface( LPDIRECTDRAWSURFACE4* lplpDDS,LPSIZE lpSize )<br />
{<br />
DDSURFACEDESC2 ddsd;<br />
HRESULT res;<br />
<br />
ZeroMemory( &ddsd, sizeof ddsd );<br />
ddsd.dwSize = sizeof ddsd;<br />
<br />
ddsd.dwFlags=DDSD_CAPS|DDSD_HEIGHT|DDSD_WIDTH|DDSD_PIXELFORMAT;<br />
<br />
ddsd.ddsCaps.dwCaps =DDSCAPS_ALPHA;<br />
ddsd.ddpfPixelFormat.dwRBitMask=0xf800;<br />
ddsd.ddpfPixelFormat.dwGBitMask=0x07e0;<br />
ddsd.ddpfPixelFormat.dwBBitMask=0x001f;<br />
ddsd.ddpfPixelFormat.dwRGBBitCount=16;<br />
ddsd.ddpfPixelFormat.dwFlags=DDPF_ALPHA|DDPF_RGB;<br />
ddsd.dwWidth = lpSize->cx;<br />
ddsd.dwHeight = lpSize->cy;<br />
<br />
<br />
res=lpDD4->CreateSurface(&ddsd,lplpDDS,NULL);<br />
if(res!=DD_OK) <br />
MessageBox(NULL,L"CreateSurface didn´t worked",NULL,NULL);<br />
<br />
switch(res){<br />
case DDERR_INVALIDPARAMS:<br />
MessageBox(NULL,L"CreateSurface INVALIDPARAMS",NULL,NULL);<br />
break;<br />
case DDERR_INVALIDOBJECT:<br />
MessageBox(NULL,L"CreateSurface INVALIDOBJECT",NULL,NULL);<br />
break;<br />
case DDERR_SURFACEBUSY:<br />
MessageBox(NULL,L"CreateSurface SURFACEBUSY",NULL,NULL);<br />
break;<br />
}<br />
}<br />
<br />
return 0;<br />
}
Please help anyone, I cannot understand what is wrong, it has to be something with the flags?
Thanks for your help!
|
|
|
|
|
Hello,
I'm wondering if anyone has experienced the
"Windows cannot find <path>\<filename>. Make sure you typed the name correctly, and then try again. To search for a file, click the Start button, and then click Search."
error when attempting to launch their MFC/C++ app. via double-clicking a file associated with the application. Oddly enough, the application will launch correctly when an associated file is dragged to the app's icon or to the app's document area (when it is open and active). This is a clue that DDE is working properly.
I have attempted to trap the error using a try/catch macro in InitInstance() and InitApplication() but to no avail. I don't think this error is being created from my application, but perhaps from Windows XP and/or Windows 2000, as the error occurs on both OS's.
Well, that's all I have for now. Thanks for your continued support.
-dotBomb
|
|
|
|
|
Is your app really located at <path>\<filename>? You can experience this behavior if you're incorrectly registering the application path. I've occasionally found this problem in my development environment, since the application working directory is just one level up the Debug or Release subdirectory.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
Want a Boost forum in Code Project? Vote here[^]!
|
|
|
|
|
Joaquín,
I understand your point, however the <path>\<filename> I wrote of is the path and filename of the associated file. This path and filename given in the error is actually the correct path and filename of the associated file I double-click. Think of this problem as double-clicking on a '.xls' file in order to launch excel with the '.xls' file loaded in the document area. Strange behavior from Windows, but not without explanation I'm sure.
Thank you,
-dotBomb
|
|
|
|
|
Umm... maybe the following will help you find the problem: Open the registry with regedit and look for HKEY_CLASSES_ROOT\.xxx (where xxx is the extension associated to your app). The value for this key should be something like "XXX.Document" , look for this and open the subkey shell/open/command : is what you see correct, or can you spot something ugly which might be explaining the problem? HTH.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
Want a Boost forum in Code Project? Vote here[^]!
|
|
|
|
|
Hey every one...
i got a question in c++
if i want to make a button and when I press it it will hold a key from my keybord.... let's say if i press the button then it will hold f1... so how to do it with c++ ?
|
|
|
|
|
can u explain your problem in detail
thanks
-----------------------------
"I Think It Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
isn't it the opposite (when you press F1, it is like you had clicked on the button) ???
TOXCCT >>> GEII power
|
|
|
|
|
maybe you got me wrong... what i want is if i click a button then it will press key... i think it is something with the key event.....
|
|
|
|
|
I am using message reflection in myButton class so what i have in the message map is as below:
BEGIN_MESSAGE_MAP(myButton, CButton)
ON_CONTROL_REFLECT(BN_CLICKED, onButtonClick)
END_MESSAGE_MAP()
the prototype for onButtonClick() is afx_msg void onButtonClick()
and this works well. But i do want the parent as well to be notified so as mentioned in the MFC doc i modified the onButtonClick to return BOOL so it is then
afx_msg BOOL onButtonClick()
But this gives a compile time error :
error C2440: 'static_cast' : cannot convert from 'BOOL (__thiscall aegis::myButton::* )(void)' to 'AFX_PMSG'
None of the functions with this name in scope match the target type.
Any suggestions or is it a yet another bug in mfc.
thanks
|
|
|
|
|
got rid of the compilation error need to use ON_COMMAND_REFLECT_EX.
So now my code compiles and runs but the handler of the parent is not invoked why??
although i do have an onButtonClick in the parent.
|
|
|
|
|
Hello all. I'm having a terrible headache with a simple class... I have this class CTransfer, and I have two constructors:
<br />
class CTransferFileInfo;
class CTransferConfig;
<br />
CTransfer::CTransfer(CTransferFileInfo* pInfo, CTransferConfig* pConfig)<br />
{<br />
m_pFileInfo = pInfo;
m_pConfig = pConfig;
}<br />
<br />
CTransfer::CTransfer()<br />
{<br />
CTransfer::CTransfer(new CTransferFileInfo, NULL);<br />
}<br />
<br />
void CTransfer::SetFileInfo(CTransferFileInfo* pInfo)<br />
{<br />
if (m_pFileInfo) delete m_pInfo;<br />
m_pInfo = pInfo;<br />
}<br />
<br />
void CTransfer::SetConfig(CTransferConfig* pConfig)<br />
{<br />
if (m_pConfig) delete m_pConfig;<br />
m_pConfig = pConfig;<br />
}<br />
It does not seem to be rather difficult, is it? Well, the headache comes here. In another class, I create a CTransfer object with the default constructor, and call immediatly SetFileInfo, something like:
<br />
CTransfer* pTransfer = new CTransfer();<br />
pTransfer->SetFileInfo(pNewFileInfo);
So the problem goes in SetFileInfo. I debugged and realized that, when deleting m_pFileInfo... the member variable has random memory assigned! Worse, the variable m_pConfig, which is supposed to be NULL, has also a random memory address!
The thing goes worse. I debugged, and when entering CTransfer::CTransfer(CTransferFileInfo*, CTransferConfig*), it assigns the correct values to the variables. But after returning, the variables goes mad and change their value into a random memory address!
It's the first thing that this happens to me. Please, I'd appreciate any help. Thanks.
|
|
|
|
|
Kith Kahnan wrote:
CTransfer* pTransfer = new CTransfer();
What value do m_pFileInfo and m_pConfig have after this statement? I would guess they need to be set to NULL in CTransfer 's default constructor.
"Opinions are neither right nor wrong. I cannot change your opinion of me. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
This are the values:
m_pFileInfo = 0x008d3de0
m_pConfig = 0x008c7550
and pTransfer = 0x008d3d30
then, m_pFileInfo = m_pConfig = 0xcdcdcdcd
Thanks for your help.
|
|
|
|
|
I guess that the sentence CTransfer::CTransfer(new CTransferFileInfo(), NULL) is actually creating another instance of CTransfer... and of course, after leaving the method, the destructor is called... I guess I'd have to write much code anyway...
|
|
|
|
|
What happens when you just do this...
CTransfer::CTransfer()
{
m_pFileInfo = new CTransferFileInfo();
m_pConfig = NULL;
}
rather than this silliness...
CTransfer::CTransfer()
{
CTransfer::CTransfer(new CTransferFileInfo, NULL);
}
|
|
|
|
|
That "silliness" you call saves me a lot of coding. The contructor has too much initialization code. Actually, it is working, but i really don't want to code that much (because this problems is going on in other classes, also with too much initialization code).
Greetings.
|
|
|
|
|
Than I would suggest you have a specific method that both constructors call to initialize your data.
Read this:
http://www.brpreiss.com/books/opus4/html/page599.html[^]
What might be happening is that the custom constructor inits the variables but when the body of the default constructor runs those variables are set to system define defaults (i.e. random noise). I could well be wrong about this, but calling a constructor from within your default constructor seems a little cheesy to me.
|
|
|
|
|
Please take into account that calling a constructor inside another constructor is just illegal C++. The fact that it seems to work is just mere luck. C++ does not allow to do this. (Incidentally, this feature is being discussed for inclusion into the next revision of the C++ standard, under the name forward constructor.)
A valid alternative, however, is the following, which uses the so-called placement new:
#include <new>
...
CTransfer::CTransfer()
{
new (this) CTransfer(new CTransferFileInfo, NULL);
} All in all, having a common initialization function, as has been suggested, is probably clearer. Hope this helps.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
Want a Boost forum in Code Project? Vote here[^]!
|
|
|
|
|
Joaquín M López Muñoz wrote:
Please take into account that calling a constructor inside another constructor is just illegal C++.
Calling a base class constructor from a derived class constructor, would that be illigal to, or do you have to call them like this:
<br />
ClassB : public ClassA<br />
{
};<br />
<br />
ClassB::ClassB() : ClassA(), SomeMemberClass1(), SomeMemberClass2()<br />
{<br />
}<br />
Multiply it by infinity and take it beyond eternity and you'll still have no idea about what I'm talking about.
|
|
|
|
|
You have to call the constructors on the initializaer list:
ClassB::ClassB() : ClassA(), SomeMemberClass1(), SomeMemberClass2()
{
}
ClassB::ClassB()
{
ClassA::ClassA();
SomeMemberClass1::SomeMemberClass1();
SomeMemberClass1::SomeMemberClass2();
}
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
Want a Boost forum in Code Project? Vote here[^]!
|
|
|
|
|
Thanks,
I guess that I've got some classes to re-write...
Multiply it by infinity and take it beyond eternity and you'll still have no idea about what I'm talking about.
|
|
|
|
|
|
Does anyone know if it is possible to subclass the list header for an IShellView so that it can be custom drawn. This is easy with an MFC list control, but I have not been able to find a way to do this with the IShellView. I like the built in features of the IShellView, but would like to custom draw the list headers to match the rest of my program.
Thanks,
Nick
|
|
|
|
|