|
You all guyz, thank you for u responses. But cedric moonen, got my point 120% right. and his solution is exactly what i needed. I was going through the Wrox "Professional MFC programming with Visual C++", and there the writer took me through the disection of the Different macros used by MFC to declare the Message Maps. they are defined in Afxwin.h.
As suggested by him, too,
ON_COMMAND_RANGE(IDC_BUTTON1, IDC_BUTTON100, OnButtonRange)
will work just fine.
Since i got some inside information from my research, i would like to share it with you guyz. Actually there is a structure for each message handler entry in the message map which is hidden from the programmers. MFC maintains an array of this structure in every class where you use
BEGIN_MESSAGE_MAP( class, baseClass)
That entry structure is something like this:
struct THESTRUCT
{
UINT nMessage;
UINT nID;
UINT nLastID;
UINT nSig;
pointerToFunctionHandler;
};
nMessage is, of course, the message to handle.
nID is, of course, of course, the of target control (for which the message is intended)
nLastID, this is the essence. If you want one function to handle multiple controls having their IDs with in a specific range. Then nID is the Lowest ID inclusive and nLastID is the highest ID.
nSig is a long value that specifies the function Signature of the handler function.
Hope this is helpful.
and Thanks, you've all been very useful.
To hit 3rd floors window you have to AIM for 5th or Higher.
|
|
|
|
|
I'm working on an email app and would like to add an "auto-fill" style functionality as they address a message.
I have an edit box where they can enter the addresses. If they hit PageDown while addressing, then a small dialog appears with a listctrl that displays all the address book aliases that match the portion of the address they have typed.
(See http://www.specialtysound.com/autofill.jpg for a screen shot)
Here's the problem: I would like the dialog to disappear if they click anywhere outside of it.
I'm creating a standard dialog with the following styles:
WS_POPUP, WS_VISIBLE, WS_CLIPSIBLINGS, WS_BORDER, WS_OVERLAPPED, DS_3DLOOK, DS_SETFONT and WS_EX_LEFT, WS_EX_LTRREADING, WS_EX_RIGHTSCROLLBAR, WS_EX_TOOLWINDOW, WS_EX_CONTROLPARENT
I instantiate the class and call DoModal().
Any help would be great. Thanks!
|
|
|
|
|
Hi,
How to add CString member variable to mfc application. FYI, I am building mfc application using visual studio .net.
Thanks
Vinay
|
|
|
|
|
Oh, man.
I suggest buying a book like 'teach youself C++ in 24 hours', or 'C++ for dummies'. For every thing like this you get answered on a forum, there will be 5 things you never think to ask, and you need to know.
In your header file, put the member variable declaration. If you look up from where you put it, the last one of these: public:, private:, protected:, will define the scope of the variable. Now you can use it within the class.
It's best to make your members private first, then expand the scope if you need to. It's also best not to make member variables public, that exposes implimentation details. Provide get and ( if warranted ) set methods instead.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
I know enogh c++ but do not know the ever changing development environment under different conditions.
I think, just by looking at the subject of my posting, readers who are looking for great/advanced questions, can skip .
comign to the actual problem.....
If I want to add a member variable in VC++ 6.0, I used to do following.
1.Select the class(in class view)
2.right click
3.choose add member variable
4.enter variable name and variable type. I can enter any type of variable because variable type is an edit box.
But in VC++ 7.0(visual studio .net), variable type is a list box which allows to choose inegral type of variables. So how to choose CString.
I entered CString manually in header file. But CString variable was taken from atl library but I want it to be taken from MFC libraries.
|
|
|
|
|
Both ways that you describe are useful only if you want to be clueless forever. The more you rely on the IDE for such simple tasks, the longer it will take for you to ever have any idea how to program, or how things are working in your chosen language/framework. I've never used that stuff, in VC6 or VC7. I'll put variables where I want them, how I want them.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
Do you think, I always use wizard to add a variable?
Wizards add code to the project and sometimes user does not know where the code was written.
But when a variable is added to project using wizard, does the programmer does not know where it was added? hhhaa
|
|
|
|
|
vchedalla wrote:
Do you think, I always use wizard to add a variable?
I dunno, you're telling the story.
vchedalla wrote:
But when a variable is added to project using wizard, does the programmer does not know where it was added? hhhaa
It's not as hard to find as when you use a wizard to add a COM method, but the principle is the same - someone who uses wizards all the time is unlikely to really understand what's going on. Besides, if you don't use them, why the question ?
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
My icons look great on XP but they look totally crappy on NT. I have True Color selected on both machines. Is this a known NT issue?
Thanks,
Ian
|
|
|
|
|
I believe NT and 2K only support icons using 4 or 8 bit (16 or 256 colors).
there is this too (from MSDN "Design Specifications and Guidelines - Visual Design" excerpt):
Note
To display icons at 48 x 48 pixel resolution, the registry value Shell Icon Size must be increased to 48. To display icons in color resolution depth higher than 16 colors, the registry value Shell Icon BPP must be set to 8 or more. These values are stored in HKEY_CURRENT_USER\Desktop\WindowMetrics.
Steve
|
|
|
|
|
Thank you much, Steve. I'll look into these registry values.
Thanks again!
-Ian
|
|
|
|
|
Steve,
Mucking with that registry value did the trick. Thank you for the fantastic and spot-on answer!
-Ian
|
|
|
|
|
Glad I could help
Steve
|
|
|
|
|
Hello,
Is it possible to make a text over the sceen?
I dont want to use a dialog only text and I want it to cover the desktop. It that possible?
|
|
|
|
|
Draw text directory onto the DC of the HWND from GetDesktopWindow()
|
|
|
|
|
|
Erh, by drawing on the HDC for the HWND returned from GetDesktopWindow(). Are there some hidden abstractions in the answer that I've missed
#include <windows.h>
int main()
{
HDC hDC = NULL;
HWND hWnd = GetDesktopWindow();
RECT rect;
if (hWnd)
{
hDC = GetWindowDC(hWnd);
if (hDC)
{
rect.top = 100;
rect.left = 100;
rect.right = 300;
rect.bottom = 300;
DrawText(hDC, TEXT("Hello World!"), 12, &rect, DT_LEFT);
ReleaseDC(hWnd, hDC);
}
}
return 0;
}
"After all it's just text at the end of the day. - Colin Davies
"For example, when a VB programmer comes to my house, they may say 'does your pool need cleaning, sir ?' " - Christian Graus
|
|
|
|
|
Exactly, as you detaile din your repsonse.
I had accidentally typed 'directory' instead of 'directly'... Oh well, that might have been the really confusing point of my answer
|
|
|
|
|
Ok,
But I tryed in MFC and I dont get it to work?
|
|
|
|
|
Let me see the code, and I'll tell you why
"After all it's just text at the end of the day. - Colin Davies
"For example, when a VB programmer comes to my house, they may say 'does your pool need cleaning, sir ?' " - Christian Graus
|
|
|
|
|
Well all I have done is to create a new MFC app,
and created a test button with the code you show. Byt
I dont get it to work.
|
|
|
|
|
I nice thing to know is: How doesn't it work?
A: Doesn't it compile?
B: Don't you get the expected result?
If A, CWnd::GetDesktopWindow() returns a CWnd *, not a HWND. use ::GetDesktopWindow(), not GetDesktopWindow().
If B, try to show a dialog after invoking DrawText(), if it doesn't show, then obviously you didn't get a HWND and a HDC. In that case, you could use GetLastError() to see why.
"After all it's just text at the end of the day. - Colin Davies
"For example, when a VB programmer comes to my house, they may say 'does your pool need cleaning, sir ?' " - Christian Graus
|
|
|
|
|
Well this is what I get;
cannot convert from 'class CWnd *' to 'struct HWND__ *'
|
|
|
|
|
I want to make a 3rd party application maintain the user focus at all times, from reading around the topic I gather that MFC hooks are the usual way of altering how windows behaves.
Could someone suggest how I could accomplish this, or a better way of achieving this. Links to some good MFC tutorials would be appreciaetd too as I haven't used MFC before.
|
|
|
|
|
I use a lot of console application for small tools or testing applicationd.
My question is , does you use tem to? or did everyone stop using them?
Is there any Console FrameWork ? a framework that help us build a console application with a simple menu (no need to be menubar) and progress bars etc, in order to make small tools with console appications even faster?
If not, will help anyone an article on this? (thinking of building mt own framework)
|
|
|
|
|