|
1) Is there a way to programatically check/uncheck the checbox in this control?
2) Is there a way to tell when the checkbox has been clicked on?
------- sig starts
"I've heard some drivers saying, 'We're going too fast here...'. If you're not here to race, go the hell home - don't come here and grumble about going too fast. Why don't you tie a kerosene rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
John Simmons / outlaw programmer wrote: 1) Is there a way to programatically check/uncheck the checbox in this control?
DTM_SETSYSTEMTIME. The WPARAM is used to set the checkbox state.
The return value from a DTM_GETSYSTEMTIME message is the checkbox state.
John Simmons / outlaw programmer wrote: 2) Is there a way to tell when the checkbox has been clicked on?
Handle the DTN_DATETIMECHANGE notification.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" - mYkel - 21 Jun '04
"There's not enough blatant self-congratulatory backslapping in the world today..." - HumblePie - 21 Jun '05
Within you lies the power for good - Use it!
|
|
|
|
|
Hi all.
I wrote an app. that relies on GDI+ 1.0, and found that it uses a huge amount of CPU, comparing it with GDI. Is this right, or am i doing something wrong?
|
|
|
|
|
Alberto_Canabal wrote: am i doing something wrong?
Yes.
Since i don't know what you're doing, i obviously can't say what. Here are some things to watch for:
- GDI+ is a good deal slower than old GDI calls for some operations. When faced with a serious performance problem, profile *everything* and look for the root cause.
- Some GDI+ features, such as antialiasing, gradiant fills, etc. are bound to make some operations slightly slower - so if your code requires a billion lines to be drawn every second, then the extra cost of making them look nice will really cost ya!
- Blitting between a memory DC and the screen in GDI+ can be considerably slower than doing so using GDI routines, especially if the two use different color depths.
|
|
|
|
|
To start monitoring things, i wrote a simple GDI+ app., which draws a static rectangle and marks a variable area with a grid. The app. doesn't use double buffering (for the sake of simplicity)...
Here is my whole OnPaint method:
<br />
CRect rect;<br />
GetUpdateRect(&rect);<br />
<br />
CPaintDC dc(this);<br />
Graphics graphics(dc.m_hDC);<br />
<br />
graphics.Clear(Color::Black);<br />
<br />
Color colorCross = Color::Red;<br />
HatchBrush oBrushCross(HatchStyleCross, colorCross, <br />
Color(0,0,0,0));<br />
<br />
Pen oPenCross(colorCross, 0.0);<br />
<br />
RectF oRect(<br />
rect.TopLeft().x + 50, <br />
rect.TopLeft().y + 50, <br />
rect.Width() - 50, <br />
rect.Height() - 50);<br />
<br />
graphics.FillRectangle(&oBrushCross, oRect);<br />
graphics.DrawRectangle(&oPenCross, oRect);<br />
<br />
Color color = Color::Yellow;<br />
HatchBrush oBrush(HatchStyleBackwardDiagonal, color, <br />
Color(0,0,0,0));<br />
Pen oPen(color, 0.0);<br />
<br />
RectF ooRect(100, 100, 200, 200);<br />
graphics.FillRectangle(&oBrush, ooRect);<br />
graphics.DrawRectangle(&oPen, ooRect);<br />
Results:
- CPU usage reaches nearly 70% (i'm working on a pretty good computer)
- Drawing is horrible...for example, when you hover another window over the dialog, it leaves "garbage", or doesn't repaint the variable area ok...
Any lights?????
Thanks!
|
|
|
|
|
Two suggestions:
1) You're drawing relative to the update rectangle. This is what's causing the "garbage" or unpainted areas on your window! For a stable drawing you want to always draw relative to the same area - in this case, the client area of the window. You can improve performance by clipping to the update area however.
2) If the window contents is stable, you'll get a *huge* improvement by double-buffering. Only redraw into the buffer when something changes, and only re-allocate the buffer when the window size changes. This can make the difference between 100% and 1-2% CPU usage while dragging a smaller window over the top of yours. Here also you can use the update rectangle to only blit the smallest possible amount of data from the back buffer to the screen.
Finally, hatch brushes are slow. The bulk of the time spent drawing in your test code is spent filling that big red hatched rectangle.
You must be careful in the forest
Broken glass and rusty nails
If you're to bring back something for us
I have bullets for sale...
|
|
|
|
|
I totally agree when you write about double buffering, but i've got an issue with that too (at this point i don't know what am i doing with GDI+)...my app needs zooming, so i'm using a CScrollView derived class (CZoomView, which i obtained here)...everithing's fine while i just drag windows (amazed how much fast is when using another brush)...but here's the but: it doesn't paint correctly when zooming...AAAAHHHHRG!
Some conclusions:
*Double buffering classes, or at least the ones i've tried, don't work OK with GDI+ unless you repaint ALL the client area, not only the clipbox (still haven't tried with CachedBitmap though)
*GDI, while not so good-looking and easy-to-use, is muuuch faster and reliable than it's + counterpart...i've even tried an MSDN sample, and it didn't repaint correctly (it was just a rectangle)...
Suggestions? (Harakiry or starting with bonsai are not acceptable ones)
|
|
|
|
|
Don't forget that you can mix GDI and GDI+ fairly easily. So if you have a GDI class that works for double-buffering, use it - switch to GDI+ only when you need it!
Example (dc is the MFC wrapper for the back buffer):
{
using namespace Gdiplus;
Graphics gfx(dc.m_hdc);
gfx.Clear(Color::Black);
}
You must be careful in the forest
Broken glass and rusty nails
If you're to bring back something for us
I have bullets for sale...
|
|
|
|
|
Hi,
in my work i have to select data from combobox in parent window and send it it to editbox in child window,
i written code in parent window button control like as fallowing..
CTransmit_ModeDlg Dlg; // assigning object for child window
Dlg.DoModal();
CString RecAddr;
GetDlgItemText(IDC_Addr_Channel1, RecAddr);// selecting data from combobox
Dlg.m_strRec_Addr=RecAddr; // assigning it to edit box in child window and m_strRec_Addr is member variable of editbox in child window.
thanking you
sheshidar patnam
|
|
|
|
|
This would never work because DoModal will 'block' until the dialog box is closed.
A better way to 'send' data from your parent dialog to your child dialog is to add method in your child dialog that will 'store' the data. You call these function before calling DoModal and in OnInitDialog of your child dialog, you just have to use this data.
Example:
class CChildDlg : public CDialog<br />
{<br />
public:<br />
void SetData(int Value) { m_Value = Value; }<br />
<br />
private:<br />
int m_Value;<br />
}
voidCChildDlg::OnInitDialog()<br />
{<br />
....<br />
}
|
|
|
|
|
THx Moonen,
i solved my problem but not exactly how u explained, i got an idea on "DoModal will 'block' until the dialog box is closed", i wrote the same code before domodal();
and it worked.
Thx again.
|
|
|
|
|
Hi,
is it possible to change the Threadname of a Thread that was created with "AfxBeginThread()"?
In C# it is quite easy, but i couldn't find out a method for C++/MFC. It would be nice to read the correct threadname in the debuggerwindow. Right now it always tells me: "The Thread 'Win32 Thread' finished with code 0 (0x0).".
Thanks,
Snow
|
|
|
|
|
<br />
<br />
<br />
#pragma once<br />
<br />
extern "C"<br />
void WINAPI SetCurrentThreadName(<br />
LPCTSTR szThreadName<br />
);<br />
<br />
extern "C"<br />
void WINAPI SetThreadName(<br />
DWORD dwThreadID, <br />
LPCTSTR szThreadName<br />
);<br />
<br />
<br />
<br />
#include "stdafx.h"<br />
#include "SetThreadName.H"<br />
<br />
#define MS_VC_STN_EXCEPTION 0x406d1388<br />
<br />
#pragma pack( push, PPSetThreadName)<br />
#pragma pack( 4 )<br />
<br />
typedef struct _SETTHREADNAMEINFO<br />
{<br />
DWORD dwType;
LPCSTR szName;
DWORD dwThreadId;
DWORD dwFlags;
<br />
} SETTHREADNAMEINFO;<br />
<br />
#pragma pack( pop, PPSetThreadName )<br />
<br />
extern "C"<br />
void WINAPI SetCurrentThreadName(<br />
LPCTSTR szThreadName<br />
){<br />
DWORD dwThreadId = GetCurrentThreadId();<br />
SetThreadName(dwThreadId, szThreadName);<br />
}<br />
<br />
extern "C"<br />
void WINAPI SetThreadName(<br />
DWORD dwThreadId, <br />
LPCTSTR szThreadName<br />
){<br />
if( IsDebuggerPresent() ){<br />
<br />
SETTHREADNAMEINFO STNInfo;<br />
TCHAR szTempName[10];<br />
<br />
ZeroMemory(&STNInfo, sizeof(SETTHREADNAMEINFO));<br />
<br />
ZeroMemory(szTempName, sizeof(szTempName));<br />
lstrcpyn(szTempName, szThreadName, 9);<br />
<br />
STNInfo.dwType = 0x1000;<br />
STNInfo.szName = szTempName;<br />
STNInfo.dwThreadId = dwThreadId;<br />
STNInfo.dwFlags = 0;<br />
<br />
TCHAR szMessage[512];<br />
wsprintf(szMessage, "Setting thread 0x%08lx name to '%s'", dwThreadId, szTempName);<br />
OutputDebugString(szMessage);<br />
<br />
__try<br />
{<br />
RaiseException( MS_VC_STN_EXCEPTION, <br />
0, <br />
sizeof(STNInfo) / sizeof(DWORD),<br />
(DWORD *)&STNInfo);<br />
}<br />
__except (EXCEPTION_CONTINUE_EXECUTION)<br />
{<br />
}<br />
<br />
}<br />
}<br />
<br />
<br />
|
|
|
|
|
|
Thanks thats what i wanted
|
|
|
|
|
every time Button1 is click, the value of CPU's program counter is read and displayed on edit box1.
Then Button2 is click, the value of CPU's program counter is read and displayed on edit box2.
My purpose is to measure how long the device reponds to computer's command.
Cheers.
MilkyWay
|
|
|
|
|
Im having problem displaying pop-up menu
i only get the beginning of a menu and submenus
i did screenshoots of that but i cant post them so i'll use ASCII
like this:
╔╗
||
||
||
|| ╔--------╗
|| |submenu|
|| ╚--------╝
||
||
╚╝
(that vertical rectangle loks like border between splitter windows and between it and the submenu is the exact amount of space as it should be for text "menu 3" to fit)
where it should be like this:
╔-------╗
|menu 1|
|-------|
|menu 2|
|-------|╔--------╗
|menu 3>|submenu|
|-------|╚--------╝
|menu 4|
╚-------╝
first i load menu in CMenu in OnInitialUpdate():
m_popUpMenu.LoadMenu(IDR_POP_UP_MENU);
then i use pop up OnRightclick()
m_popUpMenu.TrackPopupMenu(TPM_LEFTALIGN, point.x, point.y, this);
any help will do
thank you
|
|
|
|
|
hi all!
I have a problem with my directsound application.Every time i play my sound and if there is another application playing(e.g windows media player) i get corupted sound.My cooperative level is DSSCL_PRIORITY. I also have problem when trying to create DirecSound object with CoCreateInstance metod.Curently i am creating it with DirectSoundCreate metod.
Anyone have some experience with this?
Many thanks!
|
|
|
|
|
Environment: XP Pro SP2, VS.Net2003
I am setting up some context menu items that have shortcut keys associated to them. The shortcut keys are: Shortcut::CtrlShift0 to Shortcut::ChrlShift9. This how I implement it:
for( i=0 ; i<10 ; ++i )
{
miShortcuts[i]->Index = i ;
miShortcuts[i]->Text = String::Concat(S"Shortcut ", i.ToString() ) ;
miShortcuts[i]->Shortcut = static_cast<shortcut>(*dynamic_cast<shortcut *="">(Enum::Parse(__typeof(Shortcut), String::Concat(S"CtrlShift",i.ToString())))) ;
miShortcuts[i]->Click += new System::EventHandler( this, MenuItem_Shortcut_Click ) ;
}
When I compiled it, I got this error:
error C2440: 'static_cast' : cannot convert from 'System::Enum' to 'System::Windows::Forms::Shortcut'
I have tried many things but I keep ending with similar error messages. Your help is appreciated.
Thanks!
|
|
|
|
|
Hi all,
I'm seeking a class/module to help with the filtering of some data.
Things like Butterworth or Chebyshev filters, all fairly standard stuff I'm sure.
Problem is I can't seem to find any code out there?
Can you help point me in the right direction?
Cheers
--
The Obliterator
|
|
|
|
|
If you are finding nothing that can help you, you could try to implement FIR and IIR filters (quite easy). And then use programs like Matlab to know the impulse responce af a particular filter as 'Butterworth' or 'Chebyshev' and implement it with a FIR.
Matteo
|
|
|
|
|
first you need code to do FFT (Google "FFT Bourke").
then you need some code to do a filter on the FD data (Google "Butterworth Filter FFT").
Cleek | Image Toolkits | Thumbnail maker
|
|
|
|
|
Is it possible to take controll to the Microsoft document and enter text and make any changes?
I need to remove the flag that make you see the changes you have made. Is that possible to do? and if so how?
|
|
|
|
|
Which document ? Which changes ?
You mean opening a word document with your program and modify its content ? If this is the case, look for word automation.
|
|
|
|
|
how to use CFileDialog to save a file??
vj
|
|
|
|