|
In MFC, anytime you have any window (such as dialog, view, etc.), that window has a hwnd, which is accessible by the variable m_hWnd , which is declared to be HWND (which is what MessageBox wants).
|
|
|
|
|
A common value for a MFC application is AfxGetMainWnd()->m_hWnd .
AfxGetMainWnd() returns the value you set for m_pMainWnd in the YourApp::InitInstance() function. As the name suggests, it is the main application window.
If you are using it from inside a dialog, you may want to use the dialog HWND instead, although it is not necessary.
|
|
|
|
|
i have a Dialog and ListBox
i created a class to manipulate Controls: CControl
my class have function:
BOOL CControl::GetAllProcess(CListCtrl list1, int *arrProcId)
and in Dialog's function:
CControl ctr;
ctr.GetAllProcess(IDC_LIST1,arrProcId);
but can't convert int to CListBox
don't same CSharp
plz Help me...
very clearly if you have a example for me...thanks very much
sorry if my english isn't good
|
|
|
|
|
You have defined the function this way:
BOOL CControl::GetAllProcess(CListCtrl list1, int *arrProcId) but you are calling it this way:
ctr.GetAllProcess(IDC_LIST1,arrProcId); .
You can't convert from IDC_LIST1 to a CListCtrl; one is a numeric id, the other is a class. Look at the examples here on Codeproject about how to use the CListCtrl class. Basically, you need to use the resource editor to create a CListCtrl variable; a DDX statement will attach the CListCtrl variable to IDC_LIST1.
And you probably want to write the function like this:
BOOL CControl::GetAllProcess(CListCtrl& list1, int *arrProcId)
|
|
|
|
|
oh thanks for your help ..so much
|
|
|
|
|
You need to use GetDlgItem()[^] to get the window handle from the control ID.
If this is called from within a CWnd derived class this will return a CWnd object which can be cast to the list control. See CWnd::GetDlgItem()[^]
Also, window classes are generally passed around as pointers. At a very minimum they should be passed as a reference as Hans suggested.
Passing by value will create a copy of the class. Properties changed in the copied class may not reflect back on the original.
BOOL CControl::GetAllProcess(CListCtrl *list1, int *arrProcId) {
}
CControl ctr;
ctr.GetAllProcess(GetDlgItem(IDC_LIST1), arrProcId);
|
|
|
|
|
|
Hi,
I am passing a folder path to CFileDialog to save a file to that location. But It can be hidden path. How to pass only visible folder?
Is there any flag I need to pass?
|
|
|
|
|
You should check whether the path is hidden using the WIN32_FIND_DATA structure before passing it to the CFileDialog class. If the folder/file is hidden you need to check it's parent directory and again check if the parent folder is hidden and so on until you get a folder that is visible.
Use the FILE_ATTRIBUTE_HIDDEN attribute to check if the folder is hidden
I am a HUMAN. I have that keyword in my name........
_AnsHUMAN_
|
|
|
|
|
Before calling CFileFolder , call GetFileAttributes() and check the return value for FILE_ATTRIBUTE_HIDDEN .
|
|
|
|
|
hi sir/ mam i am very new to MFC can any one explain how to use HitTest method and what are the uses of it. can we use it for selecting the particular client area.for example i had drawn the text in the client area . had taken two point from LButtonDown and LButtonUP and also the MouseMove and drawn the rectangle by this point. now i want to change the bkcolor of the rectangle .... note i did not taken the editview please any one help me ........
thanking in advance
sarfaraz
|
|
|
|
|
sarfaraznawaz wrote: how to use HitTest method and what are the uses of it
HitTest is normally used to test whether a point is with in the speciifed region or not. You didn't specify the exact context like whether it is windows WM_NCHITTEST or fucntion from any MFC class. Please do.
sarfaraznawaz wrote: had taken two point from LButtonDown and LButtonUP and also the MouseMove and drawn the rectangle by this point. now i want to change the bkcolor of the rectangle
I guess you want o fill the rectangle. Do it by selecting the brush with desired color and style into the DC that you are using to draw.
http://msdn.microsoft.com/en-us/library/dd145175%28v=vs.85%29.aspx
|
|
|
|
|
thanks
i am talking about the WM_NCHITTEST...........
this how i had drawn the rectangle with hollowbrush or NULL_BRUSH because one can see the text..
dc.Rectangle(start_pt.x, start_pt.y, end_pt.x, end_pt.y);
tis are the point which i get from the mouse message LButtonDown and LButtonUP and also the MouseMove....
and now i want to change the color
|
|
|
|
|
Get familiarized with msdn documentation..
WM_NCHITTEST Message
To set the border color of the rectangle you draw, select such a pen to the DC before you call Rectangle() function. To set the fill color do the same with brush. Doesn't it work with you? Have a look at the sample at the link in last post.
|
|
|
|
|
thanks when fill it the text that i have drawn will go hide
|
|
|
|
|
Draw your text after drawing and filling the rectangle. Remember to set a different color to distinguish.
|
|
|
|
|
sorry your not getting what i want to do ......
i am trying to select the particular text i.e should be high-lated background color of text should change
|
|
|
|
|
Did you try what I wrote here[^]?
|
|
|
|
|
thanks ....
but i am not using any one CDialog, OnDraw and doc/view architecture.
i am using app class & mainframe in SD i removed all other classes and what ever text is there i had display in paint only CMainFrame::OnPaint().............
trying to develop the editor kind of application without using editview ..
i have drawn the rectangle mouse event i want change the color what ever text comes under the rectangle should not hide text that is my problem .....
|
|
|
|
|
Hello I want to gt only one digit after point so that I can get proper result from calculation like 128 * (1/1.3) instead of 128* (1/1.333333).
|
|
|
|
|
Hi,
two ways:
1.
use a rounding function; your math package sure has at least one.
2.
for numbers that fit easily in an integer, convert to integer and back; to get multiples of one tenth, do:
double roundToOneTenth(double number) {
return 0.1*(int)(10.*number);
}
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
3. Use floor() : double d = floor(1.333333 * 10.) / 10.;
|
|
|
|
|
Thanks man, Your logic is really smart..
|
|
|
|
|
Hi,
The previous answers will not round correctly negative numbers and lack flexibility. Use the built-in facilities of the Standard C++ Library:
#include <sstream>
#include <iomanip>
double Round(double val, size_t decimal)
{
std::ostringstream oss;
oss << std::fixed << std::setprecision(decimal) << val << std::ends;
std::istringstream(oss.str()) >> val;
return val;
} cheers,
AR
When the wise (person) points at the moon the fool looks at the finger (Chinese proverb)
|
|
|
|
|
While this works, converting to a string, and then back to a float is a slow way of doing it. Check my other answer for alternatives that work.
|
|
|
|