|
Im sorry, I dont understand what you say about "dialog handles retained as global variables". What I do to call the dialogs is just this:
CErrorDlg a;
a.DoModal();
In the rest of the program I do that to call different dialogs...
PS: It may be something stupid that I can´t see, but you should know that I´m new programming at Visual C++...
|
|
|
|
|
garfield185 wrote:
CErrorDlg a;
a.DoModal();
In the rest of the program I do that to call different dialogs...
Ok...
Calling DoModal() will prevent the calling thread from running until the dialog is dismissed.
Is this really what you want?
You said in your first post that you have multiple dialogs.
Are they all modal dialogs and only one is shown at any given time, or are they modal and created from different threads, or are they modeless and all created from the main thread?
Describe the behaviour of your application a little more and how you want it to work.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
Hi, I'm having an odd problem with bitmaps and I was hoping someone might have some idea of what to look for.
I'm using only VC++ and the Windows API, not MFC.
The basic goal I want to accomplish is to have one array of bitmaps, and a corresponding array of masks for these bitmaps so that I can easily draw the bitmaps transparently.
The problem is that one of the bit masks is not being created properly for some reason, even though all of the others work just fine using the same function.
So here's what I'm doing: I first create an array of bitmap handles using LoadBitmap, with MAKEINTRESOURCE called on a resource id. This works fine. Then I attempt to create a bit mask for each of these bitmaps.
The bitmap mask created, basically, as follows:
Into the function, I pass the HBITMAP to create the mask for, as variable Hbm, and I pass
the COLORREF of the color to be transparent, as Trans.
<br />
HBITMAP CreateMask(HBITMAP Hbm, COLORREF Trans)<br />
{<br />
HBITMAP Mask, o1, o2; <br />
HDC hd1, hdc2;<br />
<br />
Mask = CreateBitmap(10, 10, 1, 1, NULL);<br />
<br />
hdc1 = CreateCompatibleDC(main_HDC);<br />
hdc2 = CreateCompatibleDC(main_HDC);<br />
o1 = (HBITMAP)SelectObject(hdc1, Hbm);<br />
o2 = (HBITMAP)SelectObject(hdc2, Mask);<br />
SetBkColor(hdc1, Trans);<br />
<br />
BitBlt(hdc2, 0, 0, 10, 10, hdc1, 0, 0, SRCCOPY);<br />
<br />
BitBlt(hdc1, 0, 0, 10, 10, hdc2, 0, 0, SRCINVERT);<br />
<br />
Hbm = (HBITMAP)SelectObject(hdc1, o1);<br />
Mask = (HBITMAP)SelectObject(hdc2, o2);<br />
<br />
DeleteDC(hdc1);<br />
DeleteDC(hdc2);<br />
<br />
return Mask;<br />
}<br />
I use this function to create 6 masks, and it works fine for most of them, but for some reason the 3rd mask does not seem to be created properly. Even if I only try to create that one mask and not the other 5, it doesn't work. The mask handle is returned, and it has the correct size (10, 10), but when I try to blit it to the screen, either it doesn't show up, or it's in some weird shape that isn't correct. Even if I use the SAME bitmap to create all 6 of the masks, 5 of them come out correctly and that one, the 3rd one, is still messed up.
Here's the function I use to blit to my double-buffered HDC:
<br />
void DrawTransparentBitmap(HBITMAP bitmap, HBITMAP mask, int x, int y, int wid, int hgt)<br />
{<br />
HBITMAP orig;<br />
<br />
orig = (HBITMAP)SelectObject(DrawDC, mask);<br />
BitBlt(wobj.getBackHDC(), x, y, wid, hgt, DrawDC,0,0,SRCAND);
<br />
mask = (HBITMAP)SelectObject(DrawDC, orig);<br />
<br />
orig = (HBITMAP)SelectObject(DrawDC, bitmap);<br />
BitBlt(wobj.getBackHDC(), x, y, wid, hgt, DrawDC,0,0,SRCPAINT);
<br />
bitmap = (HBITMAP)SelectObject(DrawDC, orig);<br />
}<br />
I've tried creating the global DrawDC as variable local to the DrawTransparentBitmap function; this has no effect.
The problem is almost certainly that the mask is somehow being screwed up in its creation.
Does anyone have any ideas about what might be wrong? Am I missing some bitmap "best practice" or something (like selecting the original bitmap handles back into the HDCs, etc)?
KR
|
|
|
|
|
Hi there,
I am working on an application that checks the task manager process list and if more than one copy of an .exe file is running, it could close them all and restart it again so that just one copy be running. I could do the part that if one specified application is closing, my program can restart it but I have problem when multiple (the same application) .exe file run sometimes and makes trouble for me.
Any help would be appreciated,
Regards,
Nahitan
|
|
|
|
|
So why not be proactive rather than reactive? In other words, why not just disallow multiple instance to begin with?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
And if an application closes all other instances of itself, how could there ever be multiple
instances of itself?
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
the problem is that when customer in some circomstances closes the application by clicking on x, the application looks like to be oppened but it is still running in process list and when they attempt to reopen the appplication, two would be running and so on. the problem is that this just happen sometimes and not all the time. I could not be able to duplicate the problem in my work station and can not understand what really happens.
Regards,
|
|
|
|
|
see ma frnd there are many ways to do that, but what is ur req, one way u can query the process list of system to find the instance, 2nd u can setup a hook to taskman or read the taskman list get the pid and kill it, let me knw, i wil give u the code, i will try not promise
|
|
|
|
|
thanks for the help I think it is good to check the task manager's process list and if multiple copy of the program are running kill it and reopen it.
regards,
|
|
|
|
|
You said you check for does your program is exist or no
I think some days ago I saw a thread on the codeproject about this search on the comments for see this thread.
|
|
|
|
|
in the thread ...
CString ThreadStr ;
ThreadStr = "hiya" ;
PostMessage((HWND)lParam,WM_USER_MYTHREAD_MESSAGE,NULL,(LPARAM)new CString(ThreadStr)) ;
in the dialog ...
LRESULT MyAppDlg::OnMyThreadMessage(WPARAM wParam, LPARAM lParam)
{
CString* cs = (CString*)lParam;
How do I delete the new CString() ?
|
|
|
|
|
daveyerwin wrote: LRESULT MyAppDlg::OnMyThreadMessage(WPARAM wParam, LPARAM lParam)
{
CString* cs = (CString*)lParam;
delete cs;
codito ergo sum
|
|
|
|
|
5!
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Hello,
I have an application built with Framework1.1.
1. Will my application work in a machine where only 2.0 is present?
2. what are the steps i must do in order to make my 1.1 application work
with 2.0?
Thanks!
|
|
|
|
|
Tal S. wrote: 2. what are the steps i must do in order to make my 1.1 application work
with 2.0?
Install the .NET Framework version 1.1 (and service pack)
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Did you mean to install 2.0 .Net framework?
What if the application uses MFC6 or MFC (compiled and built at VS 2003)? Will I get any errors?
|
|
|
|
|
Tal S. wrote: Did you mean to install 2.0 .Net framework?
No. You stated that 2.0 was on the machine and not 1.1, right? .NET framework versions should
be backward compatible - your app built on 1.1 should run on 2.0.
At least that's what MS claims
Only if it doesn't work then you could try installing 1.1 I suppose. Running multiple framework
versions side-by-side is supported as well.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
I did try. I installed both 1.1 and 2.0 .Net frameworks and still it is not working.
When I run it at debug mode,I get exception before I even see my code.
The exception is at ntdll.dll. I do not know what is wrong...
Do you have any direction?
Thanks!
|
|
|
|
|
Are you running in a debugger? If not, you should be.
When the exception occurs you can look at the call stack for the thread it occurred on and trace
back to the point in your code causing the exception.
Is this a managed app? Are you compiling for CLR and using managed code?
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
I am running the application at debug mode.
As I understand, most of the code written at C# and has wrappers for unmanaged C++
(For the parts which are unmanaged and written at VC7/MFC7). It is all build at VS2003 and run well at 1.1. But! When installing the ,Net 2.0, build it, is has exception at ntdll.dll, before I can see any of the private code at the call stack. I can only see at the call stack that it has connection to ntdll.dll but no code available (assembly only!).
Does have any idea what to do next?
|
|
|
|
|
I can't imagine what's happening. If it's an MFC app, does it even make it to the app class
constructor? If so, does it make it to InitInstance()? etc...
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
It is C++/MFC application which uses C# by wrappers.
It does not make it to InitInstance(). It fails before, not at my code - at the c++ libraries. If I press continue (not break) at the debug mode, it passes the InitInstance, then the application is runnig until the first time it see any c++ like: CTime.
It seems like something at the environmet is not OK. I do not know where to look for it.
|
|
|
|
|
Tal S. wrote: If I press continue (not break) at the debug mode, it passes the InitInstance
Is it a first-chance exception? If so then it got handled by the DLL.
At least that brings you to a place you can track in your code.
Still nothing sounds related to .NET. The C# code is in a DLL?
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Not all of the C# is at dll. some of it are at libs. Is it matter?
|
|
|
|
|
I'm just wondering if you're using a DLL that needs .NET 2.0 with an app that's using 1.1.
Did everything work fine before .NET 2.0 was installed?
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|