|
WM_CLOSE is the best way. Most applications do some confirmations like "do you want to save or not?" before closing. To forcefully close the app without popping up these kind of messages, try WM_DESTROY directly.
|
|
|
|
|
The window messages you send are correct, so the problem should be something else. Is your window handle hWnd correct? How did you obtain it?
modified 13-Sep-18 21:01pm.
|
|
|
|
|
cerne1840@yahoo.com wrote: I'v tried following codes, but they do not work.
I didn't notice it. As Thaddeus Jones already told, the problem can be of the window handle.
|
|
|
|
|
when a combo-box closed up (with drop-down or drop-down-list style), I need to get its outside height.
GetWindowRect() works normally, but, when its parent window is in min (icon) state then to restore or max state, the function doesn't work - gets rect including drop-down part.
I use this way:
int iItemH=MyComboBox.GetItemHeight(-1);
int iFrmH=::GetSystemMetrics(SM_CYEDGE);
int iCmbH=iItemH+iFrmH*2+2;
The iCmbH is what I need, but code looks no good,do you have a trusted and better idea to get its height?
|
|
|
|
|
|
Thanks, but the function is not working on Win2K - our users may use win2k.
|
|
|
|
|
i did'n got what your saying
|
|
|
|
|
GetComboBoxInfo[^] does essentially the same and is supported by Windows 2000. I can't find the OS requirements of CComboBox::GetComboBoxInfo[^] but if you are sure it isn't supported in Windows 2000, you could give that one a shot.
modified on Thursday, February 10, 2011 11:29 AM
modified 13-Sep-18 21:01pm.
|
|
|
|
|
i do a HMI software, need on canvas into a text, the text can be through user operations to change size ,
It required text font will adapt to the text frame's size change, to fill the whole text frame's purpose
OnSize
{
CString title="我是中国人";
CRect rect=GetRect();
int len=title.GetLength();
m_logFont.lfHeight=LONG(rect.bottom-rect.top);//LOGFONT m_logFont;
m_logFont.lfWidth=LONG(rect.right-rect.left)//len;
}
OnDraw()
{
CFont Font;
Font.CreateFontIndirect(&m_logFont);
dc->SelectObject(Font);
dc->DrawText( GetTitle(), GetRect(), DT_WORDBREAK );
}
When drag rectangle sometimes can be complete shows the whole string, sometimes only display several characters, behind of appears not to come out, high is no problem,width sometimes is small,why???
|
|
|
|
|
Cannot you use DrawRect with DT_CALCRECT format specifier (see MSDN[^]) to obtain the correct size for the rectangle?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Can say the concrete spot ???
|
|
|
|
|
Use DrawText with the DT_CALCRECT format flag to just obtain the rectangle dimensions (the [in,out] lpRect parameter) then use again the function to actually write the string in the properly sized rectangle.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Thanks you, but, when the rectangle increases toward right ,rect.left is Fixed ,rect.right is changed,it's good, but increases toward left time, the rect.left and rect.right has had the change,why???
|
|
|
|
|
You could try to draw in a calculated (CDC::GeTextExtent(..) ) rectangle with a some fixed font and...
...in an applied zooming transformation (CDC::SetWorldTransform(..) ) to the context.
So you can stretch the rectangle (with its content) like a gummi bear...
They sought it with thimbles, they sought it with care;
They pursued it with forks and hope;
They threatened its life with a railway-share;
They charmed it with smiles and soap.
|
|
|
|
|
Hi guys,
I wanted to find out whether one can set up a test fixture to apply all tests to the same instance of the fixture object ?
Let's us take for an example the following Testclass implemented.
class SampleTest:: public CppUnit::TestFixture
{
CPPUNIT_TEST_SUITE( SampleTest);
CPPUNIT_TEST( doTest1);
CPPUNIT_TEST( doTest2);
public:
void doTest1();
void doTest2();
}
For each test in a test fixture, CppUnit creates a new instance of SampleTest class.
Thus for fixture SampleTest containing tests doTest1() and doTest2(), CppUnit will
create 2 instances of SampleTest class and calls doTest1 on the first instance, doTest2 on the second instance.
I would like to know if it is possible to create only one instance of SampleTest class that can call both the test functions?
Thanks in advance.
|
|
|
|
|
cydd wrote: For each test in a test fixture, CppUnit creates a new instance of SampleTest class.
Correct, but it is not just before the test case function is called. The cpp unit is designed to collect all the test cases initially (this happens with macro CPPUNIT_TEST - see its definition), and map them against the an instance created for them. This is to make each test case purely independent. You have to set all the possible preconditions in each test case method in such a way that the testing will be meaningful for the context.
|
|
|
|
|
Thanks for your reply.
Is there any other way to create only one instance of SampleTest class that can call on both the test functions?
|
|
|
|
|
Can't you simply write a test function that in turn calls the other two functions?
|
|
|
|
|
That will work.
But, the error report generated will not be of much help.
Say,if I have a function called testCaller() which in turn calls the two functions, doTest1 and doTest2 respectively.
If there happens an assertion failure in doTest1,the control returns without executing assert statements written in doTest2.
Also the report will say the test name only as testCaller and not the relevant function (doTest1 in this case).
|
|
|
|
|
I understand, but is that not an imaginary problem? The test should succeed. If you get an error, you would probably just go back and debug the test case anyway?
|
|
|
|
|
Hi everyone,
I am trying to do simple line plotting, i have used a CStaticCtrl on which i am trying to plot a line on a button click event,this works fine for the first time,when the button is pressed for the second time,the value is not updated,i mean the previous line is not erased and the new line is drawn
My Code
void CMainWindow::OnPumpOffClicked()
{
CRect rect;
CDC *dc=m_pic1.GetDC();
CPen pen,*oldpen;
m_pic1.GetClientRect(&rect);// m_pic1 is variable for the static control
//dc->Rectangle(&rect);
pen.CreatePen(PS_SOLID,10,RGB(255,0,0));
oldpen=dc->SelectObject(&pen);
dc->SetMapMode(MM_ISOTROPIC);
dc->SetViewportOrg(0, 148);
dc->MoveTo(x1,y1);
dc->LineTo(x2,y2);
}
Any help is appreciated
|
|
|
|
|
You really shouldn't put your drawing code in the mouse event. What you have to do instead is store the new lines coordinate when the button is clicked and refresh your control. This will call the OnPaint method in which you erase the background and draw all the lines that you stored.
If you want to use an existing charting control, you can also look at my sig: there's a link to such a control that I developed.
|
|
|
|
|
Hey,
Thanks for the reply,sir i would be very kind of u if u please explain it more detail, i mean if u can just edit my code and show me in short,i know i am asking for too much from u,but the ctrls u have developed are like a bouncer for me,thanks again
|
|
|
|
|
It's a bit too much code to write here but if you want an example, simply look at my chart control (the CChartCtrl class and more specifically the OnPaint method). What you are doing is drawing your stuff on your main window. You should in fact create a custom control and put the drawing code in your custom control (search for articles about custom controls, there are a couple for beginners on this website).
|
|
|
|
|
Hi,
I have a dialog box application. It contains one list control (CListCtrl). It filled with some data. After double clicking on any row of it new modeless dialog gets opened.
My problem is after opening new modeless dialog box, the main dialog box's row on which i have double clicked should remain selected means display it partially that it is selected. So the user can see on which row he has double clicked previously though a modeless dialog box is opened.
If have any idea please reply.
Thanks in advance.
Regards
Rajendra
|
|
|
|