|
What are you trying to do?
1) If you just want to see what the image looks like before opening and you are using one of the Windows operating systems that support thumbnails, then
you should already have preview built in.
2) If you wish to support preview on a system that does not support thumnails in the open file dialog, then you will need to subclass the open file dialog. This is covered in the MFC libraray and I believe there may be some articles at codeproject that may cover this subject.
3) If you already have a dialog that you designed, then what problems are you having: (1) is it not drawing, (2) is it not draw in the correct location.
INTP
|
|
|
|
|
for my MDI app, i have a toolbar with a drop down list that is properly initialised and created. i can capture/detect when the user selects a given item from the list.
desired functionality: whenever the user selects an item from the drop-down list, i want to change the contents of the main menubar. i read the online docs for Microsoft Visual C++ .NET regarding the CMDIFrameWnd::MDISetMenu method. at first glance this is what i want but the article suggests that we should not "call this member function if you use the framework to manage your MDI child windows".
any helpful suggestion would be appreciated. thanks.
|
|
|
|
|
I do not use .NET, but one source that might give you a clue is the book "The MFC Answer Book" (look for MFC FAQ on the internet). When using Visual C++ 6.0, you normaly create a resource for based on the view (but you can change the resource used at any time). The most effective way would probaly be to add and remove menue items directly via code (this is much harder to code and maintain).
INTP
|
|
|
|
|
I wanted to know how an mfc application responds to WM_CLOSE. I have one application which is issuing a WM_CLOSE message to another MFC application.But the other doesn't respond to WM_CLOSE instantly. It waits for the current function or method running in primary thread to return and then takes up this message. But if primary thread is not doing anything, only secondary thread is processing, WM_CLOSE is processed instantly. Please confirm that my analysis is correct..
|
|
|
|
|
It is not a matter (I believe) of how MFC responds, but of how Windows responds. You might try putting your thread to sleep momentaraly to give the other application time to process the command.
As for how mfc applications responds: that is up to the person who wrote the application.
INTP
|
|
|
|
|
Thanks, I guess I didn't write my question clearly. What I want to confirm is whether an application running a message loop responds to WM_CLOSE instantly or after finishing the current processing. I tested with my application, what I found that when I issue a WM_CLOSE message to the second application, this second application responds to WM_CLOSE only after it has finished current processing. i.e. if a Dialog class's OnInitDialog method is getting processed when I issue WM_CLOSE, WM_CLOSE is handled only after OnInitDialog returns.
Is this behavior specific to DoModal or any method which is getting called?
|
|
|
|
|
windows programs handle events serially for one window
e.g
if you are already handling an event and another event comes , it will be in the queue and after processing ur current event the next event will be processed from the Queue .
Hope it answers ur query
Live as if your were to die tomorrow. Learn as if you were to live forever.
-Mahatma Gandhi
|
|
|
|
|
Sorry I was buzy elsewere!
Quick Answer: Before any application can close it must first finish what it is doing. That is it will not receive (etc...) any new messages until it is finish with the current message (or sub-task). It is possible to end a task now, but DO NOT DO THAT (CRTL-ALT-DELETE).
Question: "Is this behavior specific to DoModal or any method which is getting called?"
Answer: Yes and No! (1) The quick answer remains the same. The difference is that a modal box is not finished until the user closes the dialog box.
P.S. No application can respond until it has finished current processing.
INTP
|
|
|
|
|
Hi, friends.
I'm make a project that contains a cList Control, when I added item to the list, the new added item always be selected. so when I added , and then click delete button, it always delete the new item.
I use GetFirstSelectedItemPosition () to get the selected item index inside delete function.
How can I de-selected the items after adding or editing?
Thanks
|
|
|
|
|
Look at SetItemState().
INTP
|
|
|
|
|
I've spent the past two days playing with sample code that is supposed to, given a main directory, allow me to select one or more subdirectories and collect stats on them including the number of files, and the total size of each subdirectory. The technique used starts with
hFind = FindFirstFile(strFind, &dataFind);
where strFind is a wildcard search string on the main directory, and dataFind is a WIN32_FIND_DATA structure. Directories are identified by
if(dataFind.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY)
in a loop that traverses the entire directory. I found that this correctly identified only a few subdirectories, but couldn't figure out why. In a later section, files within a subdirectory are found using the same technique but using
if(dataFind.dwFileAttributes == FILE_ATTRIBUTE_ARCHIVE)
as the search criterion. This, too, failed to find all the files in the subdirectory. After many hours of research and experimenting I deduced that this is a stupid way to do this task, though it was a great way to demonstrate how to use the various controls in a dialog box. The reason, it appears to me, is that the field dwFileAttributes is an OR of one or more of many attributes, and rarely just a single one, so any single value comparison on a multiple-attribute entity will fail.
So my question is, what is a proper method for reliably testing whether a directory entity is a file or a subdirectory?
"Another day done - All targets met; all systems fully operational; all customers satisfied; all staff keen and well motivated; all pigs fed and ready to fly" - Jennie A.
|
|
|
|
|
You do it like this
if (dataFind.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
and
if (dataFind.dwFileAttributes & FILE_ATTRIBUTE_ARCHIVE)
in other words, and out the bit you're interested in. I wouldn't rely on the archive bit though, it'll miss lots of files. Use FILE_ATTRIBUTE_NORMAL instead.
Rob Manderson
http://www.mindprobes.net
Paul Watson wrote:What sense would you most dislike loosing?
Ian Darling replied.
Telepathy
Then I'd no longer be able to find out everyones dirty little secrets The Lounge, December 4 2003
|
|
|
|
|
Thanks, Rob... That was sorta where my small mind was headed - performing an AND operation to isolate the particular bit of interest, then testing for equality. It's unfortunate that the authors of this book didn't take the opportunity in this example to demonstrate this option. I think it would have been very instructive to a lot of people trying to learn the language. At the very least, it would have alerted students to the fact that the Win32 and MFC APIs are full of such flag fields, and that a programmer must learn appropriate methods for dealing with them. To their credit, though, I must admit that the intent was to demonstrate how to populate the fields of several control objects, which the chapter did quite well. Maybe I'm too much a perfectionist, but I think that sample code in a textbook should be perfect. Unfortunately it is often a far cry from merely good, let alone perfect.
"Another day done - All targets met; all systems fully operational; all customers satisfied; all staff keen and well motivated; all pigs fed and ready to fly" - Jennie A.
|
|
|
|
|
You're welcome Which book are you learning from?
I'm learning C# right now - with Tom Archers Inside C# 2nd edition as my guide. Great textbook so far but I didn't fully understand his description of assemblies, manifests et al in chapter 1. No matter - I'll go back and reread that part again and again, on the assumption that I've missed something, when I need to know it.
No textbook will be perfect - the author will always make some assumption somewhere that something is so obvious that it needs no explanation. In this case I suspect it was that the constants are named FILE_ATTRIBUTE_??? and the author assumed no one would imagine they were discrete constants.
Rob Manderson
http://www.mindprobes.net
Paul Watson wrote:What sense would you most dislike loosing?
Ian Darling replied.
Telepathy
Then I'd no longer be able to find out everyones dirty little secrets The Lounge, December 4 2003
|
|
|
|
|
Rob Manderson wrote:
Which book are you learning from?
Practical Visual C++ 6, by Bates and Tompkins. It's quite good, actually, and as I mentioned, the intent of the program was to illustrate how to fill up various controls, not to enumerate all the files in a directory. I was just thinking ahead a bit. I'm looking forward to reading Tom's book, but there's no rush as no one around here is using C# yet.
"Another day done - All targets met; all systems fully operational; all customers satisfied; all staff keen and well motivated; all pigs fed and ready to fly" - Jennie A.
|
|
|
|
|
Your conclusion is correct, that dwFileAttributes is a set of bit flags.
This is just of the top of my head.
if( !(dataFind.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) )
{
}
else
{
}
if( dataFind.dwFileAttributes & (FILE_ATTRIBUTE_ARCHIVE | FILE_ATTRIBUTE_NORMAL) )
{
}
INTP
|
|
|
|
|
John R. Shaw wrote:
if( !(dataFind.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) )
{ // should be a file}
else
{ // should be a file}}
Off the top of your head that's quite reasonable - I understand the intent, despite the typo. Rob came up with much the same conclusion (see above). Thank you for your guidance - C++ is fairly new to me, but I'm finding that it's not really as bad as I'd expected.
"Another day done - All targets met; all systems fully operational; all customers satisfied; all staff keen and well motivated; all pigs fed and ready to fly" - Jennie A.
|
|
|
|
|
You are welcome! I was wondering where that curley brace went to, but it is not a typo since it ended up as part of the comment. By the way, C++ is derived from C and what you are seeing is actualy C code (since no classes are invalved).
Have a great night, day, or whaterver!
INTP
|
|
|
|
|
y'know I had to stare at the code John posted quite a long time before I saw the typo Here I was scratching my head and wondering what Roger was on (and if I could have some ) before finally seeing that errant brace.
Rob Manderson
http://www.mindprobes.net
Paul Watson wrote:What sense would you most dislike loosing?
Ian Darling replied.
Telepathy
Then I'd no longer be able to find out everyones dirty little secrets The Lounge, December 4 2003
|
|
|
|
|
It was a little more than the curly brace:
if( !(dataFind.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) )
{ // should be a file directory}
else
{ // should be a file}}
"Another day done - All targets met; all systems fully operational; all customers satisfied; all staff keen and well motivated; all pigs fed and ready to fly" - Jennie A.
|
|
|
|
|
I run an application(e.g. Test.exe) in Debug or Release mode,
without manifest file, the applcation will good.
But, I met a GDI Objects leak issue,
when I run the application with
a manifest file(e.g. Test.exe.manifest).
the follow is in the manifest file:
<br />
<dependency><br />
<dependentAssembly><br />
<assemblyIdentity<br />
type="win32"<br />
name="Microsoft.Windows.Common-Controls"<br />
version="6.0.0.0"<br />
publicKeyToken="6595b64144ccf1df"<br />
language="*"<br />
processorArchitecture="x86"<br />
/><br />
</dependentAssembly><br />
</dependency><br />
The leak will not issue, when I remove the codes from the manifest file,
or, the leak will not issue , I rename the application name(e.g. ATest.exe).
The GDI Objects leak due to manifest file?
Who can give me some comments, thanks in advance!
|
|
|
|
|
I have no idea, but the manifest from Microsoft doe not cause this problem:
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestversion="1.0">
<assemblyidentity
="" version="1.0.0.0" processorarchitecture="X86" name="CompanyName.ProductName.YourApp" type="win32">
<description>Your application description here.
<dependency>
<dependentassembly>
<assemblyidentity
="" type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorarchitecture="X86" publickeytoken="6595b64144ccf1df" language="*">
INTP
|
|
|
|
|
Why doesn't VC++ recognize:
#include <string>
I see this in all the books that I am reading, but when I use it...I get:
'string': undeclared identifier
on the line where I try to declare my strings.
Incidentally, Bloodshed's C++ compiler (Dev-C++ 4.9.8.0) doesn't recognize it either.
I also tried
#include <string.h>
#include<string>
#include<string.h>
and every other configuration I could think of, include using "" around 'string'
I now this is incredibally dumb...but there it is.
thanks!
roger
|
|
|
|
|
<br />
Why doesn't VC++ recognize:<br />
#include <string><br />
<br />
I see this in all the books that I am reading, but when I use it...I get:<br />
'string': undeclared identifier<br />
on the line where I try to declare my strings.<br />
Incidentally, Bloodshed's C++ compiler (Dev-C++ 4.9.8.0) doesn't recognize it either.<br />
<br />
I also tried <br />
#include <string.h><br />
#include<string><br />
#include<string.h><br />
|
|
|
|
|