|
Hi,
I need to terminate another instance of my application gracefully, like an "End Task"
* When the main window is active, It should work as if I clicked the "Close" Icon, with all "do you want to save.." and stuff.
* When a modal message box is open, the application should not exit, but come to foreground (this works well).
* As bonus, the "End Task" dialog if (and only if) the app is hung for a given time
I do have the main window handle of the other app.
Sending WM_CLOSE kills the app completely, posting WM_QUIT doesn't have any effect.
I could even send a custom message to a background-thread-window in the app to be closed (but would like to avoid that)
-- modified at 10:09 Thursday 27th July, 2006: clarified
|
|
|
|
|
Have you tried sending (or posting) a WM_SYSCOMMAND message with the SC_CLOSE parameter?
Just a guess, may not work
You may be right
I may be crazy
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|
|
Try sending a WM_COMMAND to your main window with the ID of your 'Exit' menu item (or whatever you use to exit normally).
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
I have two bitmaps (loaded from resources).
I want to combine thse two bitmaps side-by-side into a 3rd bitmap.
I want to put the 3rd (combined) bitmap into an image list.
The snippet below shows the two functions associated with the image list. The InitImageList() function works fine - each row in the grid shows a white bitmap image in the appropriate column. However, the BuildImageList function doesn't appear to work as intended. Essentially here's the process I'm using:
- Load all bitmaps
- Create two DC - a sourceDC and a targetDC
- select the target bitmap into the target DC,
- select the first source bitmap into the source dc
- BitBlt the source dc onto the target dc
- select the second source bitmap into the source dc
- BitBlt the source dc onto the target dc
- retrieve the bitmap from the target dc
- replace the first imagelist image with the new bitmap
For the raster operation, I've tried both SRCCOPY and SRCPAINT.
What am I doing wrong?
void CMyGridCtrl::InitImageList()
{
if (m_ResultsImages.Create(34, 21, ILC_COLOR4, 0, 1))
{
CBitmap bmp;
CBitmap* pBmpMask = NULL;
bmp.LoadBitmap(IDB_RESULTS_BOTH_CLEAR);
m_ResultsImages.Add(&bmp, pBmpMask);
SetImageList(&m_ResultsImages);
}
}
void CMyGridCtrl::BuildImageList(int nConsultID, int nLabsID)
{
UINT nImgConsult = 0;
UINT nImgLabs = 0;
switch(nConsultID)
{
case 1 :
nImgConsult = IDB_CONSULT_ORDERED;
break;
case 3 :
nImgConsult = IDB_CONSULT_RETURNED;
break;
default :
nImgConsult = IDB_NORESULTS;
break;
}
switch(nLabsID)
{
case 2 :
nImgLabs = IDB_LABS_ORDERED;
break;
case 4 :
nImgLabs = IDB_LABS_RETURNED;
break;
default :
nImgLabs = IDB_NORESULTS;
break;
}
int nTargetWidth = 34;
int nTargetHeight = 21;
int nSrcWidth = 17;
int nSrcHeight = 21;
CBitmap bmpConsult;
CBitmap bmpLabs;
CBitmap bmpTarget;
bmpConsult.LoadBitmap(nImgConsult);
bmpLabs.LoadBitmap(nImgLabs);
bmpTarget.LoadBitmap(IDB_RESULTS_BOTH_CLEAR);
COLORREF crBackground = RGB(0,0,0);
CBitmap* pOldTargetBmp = NULL;
CBitmap* pOldSourceBmp = NULL;
CBitmap* pNewTargetBmp = NULL;
CDC targetDC;
CDC sourceDC;
targetDC.CreateCompatibleDC(this->GetDC());
sourceDC.CreateCompatibleDC(this->GetDC());
pOldTargetBmp = targetDC.SelectObject(&bmpTarget);
pOldSourceBmp = sourceDC.SelectObject(&bmpConsult);
targetDC.BitBlt(0, 0, nTargetWidth, nTargetHeight, &sourceDC, 0, 0, SRCPAINT);
pOldSourceBmp = sourceDC.SelectObject(&bmpLabs);
targetDC.BitBlt(nSrcWidth, 0, nTargetWidth, nTargetHeight, &sourceDC, 0, 0, SRCPAINT);
pNewTargetBmp = targetDC.SelectObject(pOldTargetBmp);
m_ResultsImages.Replace(0, pNewTargetBmp, NULL);
}
I also tried doing this:
targetDC.BitBlt(nSrcWidth, 0, nTargetWidth, nTargetHeight, &sourceDC, 0, 0, SRCPAINT);
pNewTargetBmp = targetDC.SelectObject(pOldTargetBmp);
CBitmap newBmp;
BYTE bmpBits[4096];
memset(&bmpBits, 0, sizeof(bmpBits));
DWORD nSize = pNewTargetBmp->GetBitmapBits(sizeof(bmpBits), &bmpBits);
newBmp.CreateBitmap(nTargetWidth, nTargetHeight, 1, nSize, (void*)bmpBits);
m_ResultsImages.Replace(0, pNewTargetBmp, NULL);
One last note - Whoever is voting my messages a "1" is acting real f***in' mature. Act like a f***in' grownup or leave.
-- modified at 13:06 Thursday 27th July, 2006
|
|
|
|
|
I wrote a tool a while back that I use to see exactly what every step in my code is doing when working with bitmaps. Check it out, maybe it will help you spot the problem.
http://www.codeproject.com/tools/imageviewer.asp[^]
You may be right
I may be crazy
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|
|
I put all the components where instructed, and it doesn't seem to do anything. Does it matter that I'm using VS2005?
Nevermind - stupid programmer tricks.
-- modified at 12:41 Thursday 27th July, 2006
|
|
|
|
|
Well, the "targetDC" device context appears to change when I copy the images to it, but when I try to do the last "pNewTargetBmp = targetDC.SelectObject()" call in the code above, the viewer won't show the bitmap.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
I found that the resulting bitmap on the last SelectObject call is nothing but a single pixel centered in what would be the image.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
The single pixel is the default bitmap that is selected into a memory device context. If that is what you see that means you are not successfully selecting a bitmap into that device context. You have to create a memory bitmap the size and bit depth required, and use SelectObject() to attach it to the memory device context. The memory device context will then do all it's drawing onto that bitmap.
You may be right
I may be crazy
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|
|
John Simmons / outlaw programmer wrote: I found that the resulting bitmap on the last SelectObject call is nothing but a single pixel centered in what would be the image.
Are you looking at bmpTarget or at pNewTargetBmp. Your final image should be in bmpTarget at this point.
You may be right
I may be crazy
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|
|
targetDC.BitBlt(0, 0, nTargetWidth, nTargetHeight, &sourceDC, 0, 0, SRCPAINT);
ShowBitmap(bmpTarget);
pOldSourceBmp = sourceDC.SelectObject(&bmpLabs);
targetDC.BitBlt(nSrcWidth, 0, nTargetWidth, nTargetHeight, &sourceDC, 0, 0, SRCPAINT);
ShowBitmap(bmpTarget);
targetDC.SelectObject(pOldTargetBmp);
m_ResultsImages.Replace(0, &bmpTarget, NULL);
You may be right
I may be crazy
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|
|
I use some console application running it from inside VC project and I want to redirect its output to file
bool runprocess(wchar_t *cmnd)
{
SECURITY_ATTRIBUTES sattr;
memset(&sattr,0,sizeof(sattr));
sattr.nLength = sizeof(sattr);
sattr.bInheritHandle = true;
STARTUPINFO sInfo;
memset(&sInfo,0,sizeof(sInfo));
PROCESS_INFORMATION pInfo;
memset(&pInfo,0,sizeof(pInfo));
sInfo.cb = sizeof(sInfo);
sInfo.dwFlags = STARTF_USESTDHANDLES;
bool res = CreateProcess(0,cmnd,0,0,true,NORMAL_PRIORITY_CLASS|CREATE_NO_WINDOW,0,0,&sInfo,&pInfo);
if(res)
WaitForSingleObject(pInfo.hProcess, INFINITE);
return res;
}
runprocess(L"consoleapp.exe >output");
But the file output is not created though consoleapp worked normally?
How to get its output without reading hStdInput, hStdOutput from STARTUPINFO structure?
9ine
|
|
|
|
|
Since you are using the STARTF_USESTDHANDLES flag, you also need to open files for standard input, output, and error, and set their HANDLE values in the STARTUPINFO structure. Also, remove the "> output" from the command line, since you are already doing the redirection.
Software Zen: delete this;
|
|
|
|
|
hi i want to use API PfBindInterfaceToIPAddress(ihandle,PF_IPV4,(PBYTE)"202.165.250.50") and in this i had to supply the ip adress as byte but i want to do with byte like
byte i[]={205,25,236,25};
but it gives error so i had to use as in above api but it did not work tell me how to do that.
i thinks so this function faildue to that
-- modified at 9:42 Thursday 27th July, 2006
|
|
|
|
|
you could simple split the string by searching the '.' characters, but it can become mmuch more complicated if you have to check if the ip is valid...
consider this :
"304.6458.0.12"
|
|
|
|
|
int i[]={202,165,250,50};
AfxMessageBox("Step 1 Done");
PBYTE ip=(PBYTE)i;
I had used this as ip but still functin does not succeed i think it has some other problem.
Tasleem Arif
|
|
|
|
|
tasleem143 wrote: int i[]={202,165,250,50};
AfxMessageBox("Step 1 Done");
PBYTE ip=(PBYTE)i;
If you want a BYTE array then declare it as a byte array
BYTE i[] = {202, 165, 250, 50};
You may be right
I may be crazy
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|
|
I'm finding a solution to make the mouse pointer to hourglass during wait for some process in my project.
Please give me some information of this.
|
|
|
|
|
{
CWaitCursor foo;
...wait for some process in your project...
}
when foo goes out of scope, the cursor will become an arrow again
|
|
|
|
|
If this is with MFC, use CWaitCursor . Otherwise, handle the WM_SETCURSOR message.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
|
I use VC++ 6.0 and i have a date picker. My problem is that whenever I start the program it start with the date being set to 01.01.1970. How can I set it to start with today, let's say?
|
|
|
|
|
tanarnelinistit wrote: How can I set it to start with today, let's say?
With the SetTime() method.
"Money talks. When my money starts to talk, I get a bill to shut it up." - Frank
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi,
I have used CRITICAL_SECTION to make my code thread safe and I was wondering if there is some way of testing it. I can call the code from two different threads and the code doesnt appear to screw up - but how do I really know that the cricial sction has blocked one thread until the other has completed rather than just being (un)lucky and both threads never actually called at the same time?
Is there something I can put in there to record that two threads have attempted to access the same resource?
TIA
Tony
|
|
|
|
|
Do you always test things like that ? Did you check if the if/else statments were doing their job, or if CreateThread is really creating a new thread ?
Seriously, if you use them like it is documented, they will work how it is documented. No need to be paranoid .
|
|
|
|
|