|
This code snippet is used to bring up a confirmation dialod box to close the window only when the top right close box is clicked not for any other methods of closing like File>Exit and Syatem Close and Alt+F4. The behaviour of getAsyncKeyState() is not undersatndable here...
LRESULT CALLBACK WndProcedure(HWND hWnd, UINT Msg,WPARAM wParam, LPARAM lParam)
{
LRESULT result=0L;
int k=0;
switch(Msg)
{
case WM_NCLBUTTONDOWN:
if (wParam!=HTCLOSE) // allow clicks on system menu to continue and proceed
{
DefWindowProc(hWnd, Msg, wParam, lParam);
return 0;
}
GetAsyncKeyState(VK_LBUTTON);
break;
case WM_NCLBUTTONUP:
if ((int)wParam ==HTCLOSE && !(GetAsyncKeyState(VK_LBUTTON)))
{
k=MessageBoxA(NULL, "Do u wish to close ", "getasynckeystate", MB_YESNO);
if (k==IDYES)
{
PostMessage(hWnd, WM_CLOSE, 0, 0L);
return 0;
}
else
{
DefWindowProc(hWnd, Msg, wParam, lParam);
}
}
DefWindowProc(hWnd, Msg, wParam, lParam);
break;
case WM_DESTROY:PostQuitMessage(WM_QUIT);// then close it
break;
default : return DefWindowProc(hWnd, Msg, wParam, lParam);// Process the left-over messages
}
return result;
}
Bibhakar Ranjan
|
|
|
|
|
GetAsyncKeyState[^].
Please, read the posting guidelines before posting a message, format your code with the pre or code tag otherwise it is difficult to read.
Furthermore, you shouldn't use MessageBoxA directly, but MessageBox. So that your compile will still compile if you switch UNICODE on or off.
|
|
|
|
|
...you can see also suggest the related GetAsyncHi and GetSynchronousHello functions.
BTW Good morning Cedric.
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
|
|
|
|
|
Hello mister Pallini
Sorry, but I didn't get what you were trying to say. My brain is still not fully operational in the morning
|
|
|
|
|
folks,
I need help on how to write a C/C++ code to compute the Gaussian and Laplacian Pyramids at 5 levels.
Using PGM image format as the input. Please help
|
|
|
|
|
|
Is this is Debug or Release mode?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
|
Usef Marzbani wrote: It's On Release Mode
Enjoy!
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
|
I was recently forced to switch from VC6 to VC2008. Many projects to convert, many errors to fix, many days to -- well -- spend. One day I recompiled and registered a MFC ActiveX control. That went fine. I had a few projects that use that control, so I removed the old H/CPP wrapper files from one of them and imported the control using Project -> Add Class -> MFC Class From ActiveX Control. The wizard re-generated H/CPP files, containing wrapper class for the control. When I recompiled the project I got many errors saying dozens and dozens of Get/Set methods are not members of my control (wrapper). I looked into generated H file of the wrapper class and found out the compiler was right: there were no Get/Set methods for any of the properties contained in the control.
After a few tries and failures I decided to start from the scratch. I created a simple MFC ActiveX control containing only two properties -- Prop1 and Prop2 of type LONG -- and two empty methods -- Method1 and Method2. All checkboxes and radio buttons in wizards were left on their default values while doing that. I imported the control the same way as before into a newly created MFC application and got the same problem: wrapper class contained only Method1 and Method2, but no Get/Set methods for the properties Prop1 and Prop2.
What am I doing wrong?
--
Vladimir Svrkota,
CardWare
Novi Sad, Serbia.
|
|
|
|
|
Hi Vladimir
I run exactly in the same problem with VS2005. In case you find a solution, please inform me THANK YOU VERY MUCH!!!.
I need the import over ActiveX because this generates a CWND derivated class. However, i get all properties and also events (which are missing too for ActiveX class) when i generate a class by TypeLib (actualle this generates 2 Files, the events are separated).
Maybe it´s possible to take from typelib generated files the missing parts and hack them in the file from the ActiveX import. A nuisance, however!
Best regards
Stefan
|
|
|
|
|
Rehi
ok, i have a weird solution, but it seems to work:
Starting from a scratch container:
1.1) Insert ActiveX in resource editor
1.2) Assign a control variable. This generates a CWND derivated class with all props, events can be assigned by adding event handler and so on. Update is difficult however, except one deletes always the control and redo it (maybe even the way with less effort).
Anyway:
Updating ActiveX ( added method, event, whatever )
2.1 Remove every file for control declaration from the project (.h, .cpp) by destroying it!
2.2 leave project, delete the .ncb file, restart project but do not compile anything that would remake the ncb file
2.3 Add the control by the MFC ActiveX class. Name will be different by default then for 1)
2.4 Add the control by the MFC TypeLib, choose there the methods AND events. this will generate 2 more header file types of similar name
2.5 copy the missing parts form the typelib header files into the activex class (event block, property)
2.5 Destroy the generated typlib files, delete the includes
2.6 Remove added includes (in case they were already defined) of afxdisp.h in stdafx.h and the control header file in your main application - else you get after some new class inserts a long list of same include definitions.
and only once after you did 1)
3.1 Destroy the control files from 1)
3.2 Replace the object class from 1) by the new activeX class
Seems to work, at least in a very simple test
Regards
Stefan
modified on Wednesday, June 25, 2008 4:51 AM
|
|
|
|
|
Stefan_L_01 wrote: 1.1) Insert ActiveX in resource editor
1.2) Assign a control variable. This generates a CWND derivated class with all props, events can be assigned by adding event handler and so on. Update is difficult however, except one deletes always the control and redo it (maybe even the way with less effort).
Yes, this is the same solution I accidentaly discovered, take a look at this thread[^] in microsoft.public.vc.mfc newsgroup.
This "trick" gave me Visual C++ 6 compatible h/cpp files and that was all I needed at the time. Fortunately, my OCX control won't be needing any changes in the near future, but it's nice to have your solution when it comes to that. Thank you.
By the way, while googling around I found out this problem appeared in the first release of Visual Studio .NET (version 7.0, a.k.a. 2002), it remained in VS2003, VS2005 and it's quite strange it's still present in the most recent VS2008, so many years later.
--
Vladimir Svrkota,
CardWare
Novi Sad, Serbia.
|
|
|
|
|
btw: do you know how to delete a method, property or event from an aciveX Projekt in VS200x ?? I can´t find a way to do it.
At the moment it looks to me that i have to remove it manually with the problem that i have to renumber the odl indizes by hand argh (interrupted number order seems to cause problems)
Best regards
Stefan
|
|
|
|
|
Stefan_L_01 wrote: btw: do you know how to delete a method, property or event from an aciveX Projekt in VS200x ?? I can´t find a way to do it.
No, sorry.
--
Vladimir Svrkota,
CardWare
Novi Sad, Serbia.
|
|
|
|
|
I've created a unicode HeaderControl (window class name WC_HEADERW).
I'm adding items something like this:
HDITEMW headerItem;
memset( &headerItem, 0, sizeof(headerItem) );
headerItem.mask = HDI_LPARAM | HDI_WIDTH|HDI_FORMAT|HDI_TEXT;
headerItem.lParam = (LPARAM)j;
headerItem.pszText = LPSTR_TEXTCALLBACKW;
headerItem.cxy = 80;
headerItem.fmt = HDF_LEFT;
int err = SendMessage( headerWnd_, HDM_INSERTITEMW, (WPARAM)j, (LPARAM)&headerItem );
That works fine. I get a HDN_GETDISPINFOW notification. However the iItem in the NMHDDISPINFOW structure is always some bizarre number, i.e. it's not "0" or "1" etc, like one would expect. I googled a bit and didn't find much of a resolution to this. Has anyone else every gotten this to happen and how do you deal with it? Since I'm storing the index in the lParam I can see that is being sent correctly and work around this, but it's kind of silly to say the least.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
VCF Blog
|
|
|
|
|
Jim Crafton wrote: window class name WC_HEADERW
Isn't that a Macro? Isn't the class name "SysHeader32"?
led mike
|
|
|
|
|
Yeah but my understanding is that's what you're supposed to use (presumably in case our good buddies in redmond change the name). So there's one for unicode and one for ansi.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
VCF Blog
|
|
|
|
|
Why are you using the W versions? I mean theres W, A and Generic (or whatever) where Generic is defined by your compilation mode of UNICODE or ANSI. Why aren't you just using it that way?
led mike
|
|
|
|
|
What OS are you on? I find it suspicious that iItem is the first member after the NMHDR struct that might be different sizes on different WINVERSIONs
led mike
|
|
|
|
|
XP.
All the other members in the struct look OK. And it correctly uses the text I give it. It's as if the iItem is simply being ignored. I found a post from a few ago that someone else had apparently run into a problem like this, but no one ever replied back to him.
I used Spy++ and confirmed that the header was created as a Unicode wnd proc. It's correctly handling (and giving out) unicode messages, except for this oddity.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
VCF Blog
|
|
|
|
|
The final release of the Visual C++ 2008 Feature Pack is now available for download. This release provides several exciting features for C++ developers, such as a major update to MFC and an implementation of TR1. These features are fully covered under Microsoft’s standard support policies.
The Feature Pack is available free of charge to any Visual Studio 2008 Standard or above customer. The download can be found at Visual C++ 2008 Feature Pack Release.
Using the included MFC components, you can create applications with the “look & feel” of Microsoft’s most popular products – Microsoft Office, Visual Studio and Internet Explorer. Some of the interesting MFC components in the Feature Pack include:
- Office 2007 Ribbon Bar: Ribbon, Pearl, Quick Access Toolbar, Status Bar, etc.
- Office 2003 and XP look: Office-style toolbars and menus, Outlook-style shortcut bar, print preview, live font picker, color picker, etc.
- Visual Studio look: sophisticated docking functionality, auto hide windows, property grids, MDI tabs, tab groups, etc.
- Internet Explorer look: Rebars and task panes Vista theme support
- “On the fly” menus and toolbar customization: users can customize the running application through live drag and drop of menu items and toolbar buttons
- Shell management classes: use these classes to enumerate folders, drives and items, browse for folders and more
For more information on the new MFC support:
TR1 (“Technical Report 1”) is a set of proposed additions to the C++0x standard. Our implementation of TR1 contains a number of important features such as smart pointers, regular expression parsing, containers (tuple, array, unordered set, etc) and sophisticated random number generators.
More information on TR1 can be found at the sites below:
|
|
|
|
|
Hello to everyone,
I've written an application in VC++ 6 using MFC to connect to a database (access db). The application simply read and write data to the mdb file through CRecordset and ODBC drivers. The program works fine on XP (and also on 98) but it does not work in Vista. It seems like the program does not find the mdb.I receive an error as: .... odbc acces driver... c:\programma\database.mdb ..path is not valid. The path exists and the db is there but i still receive the error. may be something abiout permissions, UAC ecc...?
Can someone help me?
Thank you very much.
oko
|
|
|
|
|
I think you need to check your CRecordsetDerived::GetDefaultConnection() to see if you define an appropriate Connection String.
You shouldn't leave the default Connection String after AppWizard!
|
|
|
|
|