|
maladuk wrote: void ShowResultDlg::OnPaint(){
CPaintDC dc(this); // device context for painting
}
Are you some operations in this function ?
|
|
|
|
|
No, I have not. What should go in there?
Thanks!
maladuk
|
|
|
|
|
Implemenation of DrawItem seems to be problem there.
|
|
|
|
|
OK. I will start looking into it. If you think of something particular, please let me know.
Thanks a lot !
maladuk
|
|
|
|
|
Here it is, It was logical error, For time being I've removed a if case to modify code.
void CColorCheck::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
CRect rc;
CRect rect(13,1,11,11);
CRect focusRect, btnRect;
focusRect.CopyRect(&lpDrawItemStruct->rcItem);
disabled = RGB(100,100,100);
CSize captionSize;
const int bufSize = 512;
TCHAR buffer[bufSize];
GetWindowText(buffer, bufSize);
captionSize = pDC->GetTextExtent(buffer, strlen(buffer));
btnRect.SetRect(16,1,16 + captionSize.cx + 9,15);
focusRect.SetRect(18,0,16 + captionSize.cx +6, 15);
int id = GetDlgCtrlID();
UINT state = lpDrawItemStruct->itemState;
UINT action = lpDrawItemStruct->itemAction;
if (action == ODA_FOCUS)
drawFocus = TRUE;
CPen normRect(PS_SOLID, 1,NULL_PEN);
CPen* m_normRect = pDC->SelectObject(&normRect);
pDC->SelectStockObject(NULL_BRUSH);
pDC->DrawText(buffer, strlen(buffer), btnRect, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
DrawCheckCaption(pDC, btnRect, buffer, newTextColor);
pDC->FillSolidRect(2,2,11,11,newColor);
normRect.DeleteObject();
CPen normRect1(PS_SOLID, 1,RGB(80,80,80));
CPen* m_normRect1 = pDC->SelectObject(&normRect1);
CPoint startPt = pDC->MoveTo(1,13);
pDC->LineTo(1,1);
pDC->LineTo(13,1);
normRect1.DeleteObject();
CPen normRect2(PS_SOLID, 1,RGB(100,100,100));
CPen* m_normRect2 = pDC->SelectObject(&normRect2);
CPoint startPt1 = pDC->MoveTo(0,14);
pDC->LineTo(0,0);
pDC->LineTo(14,0);
normRect2.DeleteObject();
CPen normRect3(PS_SOLID, 1,RGB(255,255,255));
CPen* m_normRect3 = pDC->SelectObject(&normRect3);
CPoint startPt2 = pDC->MoveTo(14,0);
pDC->LineTo(14,14);
pDC->LineTo(0,14);
normRect3.DeleteObject();
CPen normRect4(PS_SOLID, 1,RGB(180,180,180));
CPen* m_normRect4 = pDC->SelectObject(&normRect4);
CPoint startPt3 = pDC->MoveTo(13,1);
pDC->LineTo(13,13);
pDC->LineTo(13,1);
normRect4.DeleteObject();
if (checkFlag == 1)
{
pDC->FillSolidRect(2,2,11,11,newColor);
CPen normRect5(PS_SOLID, 1, newArrowColor);
CPen* m_normRect5 = pDC->SelectObject(&normRect5);
CPoint startPt2 = pDC->MoveTo(4,7);
pDC->LineTo(7,11);
pDC->LineTo(10,3);
CPoint startPt3 = pDC->MoveTo(4,8);
pDC->LineTo(7,9);
pDC->LineTo(9,4);
normRect5.DeleteObject();
}
if (action & ODA_SELECT && checkFlag == 1)
pDC->FillSolidRect(2,2,11,11,newColor);
else if (action & ODA_SELECT && checkFlag == 0)
{
pDC->FillSolidRect(2,2,11,11,newColor);
CPen normRect5(PS_SOLID, 1, newArrowColor);
CPen* m_normRect5 = pDC->SelectObject(&normRect5);
CPoint startPt2 = pDC->MoveTo(4,7);
pDC->LineTo(7,11);
pDC->LineTo(10,3);
CPoint startPt3 = pDC->MoveTo(4,8);
pDC->LineTo(7,9);
pDC->LineTo(9,4);
normRect5.DeleteObject();
}
if( ( state & ODS_FOCUS ) ^ ( oldState & ODS_FOCUS ) ||( !drawFocus && ( state & ODS_FOCUS ) ) )
DrawFocusRect(lpDrawItemStruct->hDC, (LPRECT)&focusRect);
else if (state & ODS_DISABLED)
{
pDC->FillSolidRect(2,2,11,12,RGB(192,192,192));
DrawCheckCaption(pDC, btnRect, buffer, GetDisabledColor());
}
oldState = state;
oldAction = action;
}
|
|
|
|
|
Fantastic!
It works!
Thanks a lot.
malduk
|
|
|
|
|
You certainly deserve a 5. I am sorry I did'nt give it right away.
maladuk
|
|
|
|
|
Do you have any paint on your dialog?
|
|
|
|
|
Theres a OnPaint function in the dialog class (see code in answer above). But putting calls like m_chekbox.RedrawWindow(),
m_chekbox.UpdateWindow(),
m_chekbox.Invalidate()
etc. does not solve the problem.
maladuk
|
|
|
|
|
Hello everyone,
I was just wondering if it is possible to build a Window Application which can monitor a Third-Party software's activities?
What I mean by that is to be able to know which Button is clicked in a certain 3rd-party application. Let's say you have your "MS words" open and you are working on a document. Once you click on buttons like, Bolld, Italic, Save As, Save, Print etc..., your window application can tell you specificly what action was requested?
These are Learing question and please feel free to share with me your suggestions.
Thank you very much for your time.
Khoramdin
|
|
|
|
|
Yes - look into Windows Hooks. Specifically, I think a CBT hook can help you with things like this.
Trivia: MFC (in VC++ 6.0 at least) uses CBT hooks internally for certain functionality.
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
If you've got visual studio installed, try launching Spy++ (in VS's tools menu) - that'll show you all the windows messages an application is receiving, which can tell you which buttons, menus, etc are being clicked
|
|
|
|
|
I am writing a program where I want a sound file to play while I update the main window. I have everything implemented with the sndPlaySound() function, but when the program runs, it becomes unresponsive as long as the sound clip is running. That is, if the user tries to move the window, the whole thing goes white until the function that is updating the window is finished as well as the sound has stopped playing.
I implemented a second thread to try to do nothing but call the sndPlaySound function, but that did not work either. It played the sound, but the window still goes unresponsive if anything interrupts in my functions.
Does anyone have ideas on how to do this properly?
I have searched through the multi-threaded posts, but haven't found anything so far.
Please help, if possible. Or point me in another direction on how to implement this properly.
Thanks.
|
|
|
|
|
You can use the SND_ASYNC flag... Look up the documentation for the PlaySound(...) function.
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
I am already using the SND_ASYNC flag on sndPlaySound function.
It seems that the drawing of the window doesn't happen once the user clicks anything in the window.
|
|
|
|
|
Are you using any other flags? You might not be combining them correctly. I have used the SND_ASYNC flag lots of time and never had it stall anything like you are describing.
You do not have any code that is waiting for the sound to finish, do you?
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
No, I am not using any other flags in the sndPlaySound function. That seems to be working. What i am having a problem with (now that I look at it further), is in my ability to update the window as I need to. I am using a simple 'wait until X amount of time has passed', then I update some values, call Invalidate(); followed by a UpdateWindow().
This all works unless, in the middle of my function where I am drawing the window, the user clicks my window. Then, it doesn't update until the very end of the function and I am not sure why.
I originally thought that maybe having the sound play on another thread would help, but it isn't.
|
|
|
|
|
If your "wait until X amount of time has passed" implementation is a blocking one, like calling Sleep(...) or going into a spin, you will not be able to pump any messages, so you will not get the Paint message to update the screen.
For example, if you are trying to do some cheap animation using old-school-style techniques in a loop, it will not work the same under Windows.
If you are doing the above, you can change your wait to use a Timer message, and then when the timer message fires, you can do your updates.
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
Thank you for the help. Can you point me in the direction of Timer message info? I have never heard of this before.
Thanks again.
Josh
|
|
|
|
|
Look up the WM_TIMER message and the SetTimer(...) function. If you need high-accuracy timers, look up multimedia timers.
Peace!
-=- James Please rate this message - let me know if I helped or not!<HR> If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! See DeleteFXPFiles
|
|
|
|
|
That was it, thank you. I appreciate the help.
|
|
|
|
|
How can i access the exact hardware configuration details using Registry in VC++?Can u please give me with a piece of code?
|
|
|
|
|
V.Natarajan wrote: How can i access the exact hardware configuration details...
Of what?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
For all Hardware devices namely USB ports,D-I/O Ports & COM Ports respectively,which are currently connected to the system.Please explain with code using VC++.
|
|
|
|
|
V.Natarajan wrote: For all Hardware devices namely USB ports...& COM Ports...
Try the Win32_USBController , Win32_USBControllerDevice , Win32_USBHub , and Win32_SerialPortSetting WMI classes.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|