|
I would still suggest using vector or list. Both are STL templates and do not have very much overhead. All the code you need is in header files and there is no DLL to distribute.
If you want to allocate a large block of memory and then give some of it back to the OS the way to do that is using VirtualAlloc() with MEM_RESERVE flag set then use MEM_COMMIT to commit a block when you use it. See Reserving and Committing Memory in the MSDN help. I do this when I scan medical images. Before a scan I know the image will be no bigger than 60MB but it may only be 33MB (depending on the size of the film) so I use this method to trim the memory usage after the scan.
John
|
|
|
|
|
Hi all,
I'd like to generate .dsp and .dsw files from another
format (e.g. XML). Does anyone know if there's a tool
that can do this ?
Thanks,
Phil.
|
|
|
|
|
Probably not, but you can create it yourself. Check MSDN for wizards and add-ins for VS.
|
|
|
|
|
I can't get SHGetFileInfo's SHGFI_ICONLOCATION to work. (I'm on WinXP.) That option requests the path to the file that contains the icon for a given file type.
Here's my code:
#include <windows.h>
#include <stdio.h>
void main()
{
SHFILEINFO fileInfo = {0};
if (SHGetFileInfo(".txt", FILE_ATTRIBUTE_NORMAL, &fileInfo, sizeof(fileInfo),
SHGFI_USEFILEATTRIBUTES|SHGFI_ICONLOCATION|SHGFI_TYPENAME))
{
printf("file type: '%s'\n", fileInfo.szTypeName);
printf("icon file: '%s'\n", fileInfo.szDisplayName);
printf("icon index within icon file: %d\n", fileInfo.iIcon);
}
else
printf("failed\n");
}
The output I get is:
file type: 'Text Document'
icon file: ''
icon index within icon file: 3
As you can see, it correctly determines the file type. Also '3' is correct -- I can see that in the registry (under "txtfile"). But the filename is missing, even though it is there in my registry.
I've tried a few variations -- e.g. different extensions, and different sets of SHGFI_* flags. Anyone know how to get this to work?
Thanks -mike
|
|
|
|
|
try
::memset(&fileInfo, 0, sizeof(SHFILEINFO));
before you call the function
|
|
|
|
|
Actually the code does the equivalent of the memset() already. It starts with
SHFILEINFO fileInfo = {0};
... and, per standard C/C++, "= {0}" will initialize the ENTIRE struct (not just the first member) to all zeroes.
Mike Morearty
<a href="mailto:mike@morearty.com">mike@morearty.com</a>
<a href="http://www.morearty.com">http://www.morearty.com</a>
|
|
|
|
|
I posted this couple of weeks ago, and didn't finished it until today ...
Am I Stupid ? Did I missed something ?
I want to be notified when my slider control receives the input focus...
...
afx_msg void OnSliderFocus(NMHDR * pNotifyStruct, LRESULT * result );
... Should the following be called When I either click with the mouse on the slider ? or when I TAB to it ?
ON_NOTIFY( NM_SETFOCUS, IDC_SLIDER1, OnSliderFocus )
...
void CTestColorControlDlg::OnSliderFocus(NMHDR * pNotifyStruct, LRESULT * result )
{
ASSERT( 0 );
}
...
Thanks, I'm clueless
Maximilien Lincourt
For success one must aquire one's self
|
|
|
|
|
Maximilien wrote:
Should the following be called When I either click with the mouse on the slider ? or when I TAB to it ?
I think all of the above is true
|
|
|
|
|
Can someone point me to an article on how to add a second window to my application (using API)?
I know that you might just tell me to use Dialogboxes, but I would rather just use another window. I made it as far as making a second window class, but am not sure what to do about the mainwindow loop. Also, what to do about the second window proc. And I'm not talking about a child window, I'm talking like in Visual Basic when you add a second form to the project.
I checked out the faq, but there doesn't seem to be anything applicable...
While we're at it, how would you make a window so that the user can't change it's size?
Thanks guys.
|
|
|
|
|
Which kind of application do you have ? MDI, SDI, Dialog ? What will be the second window for ?
AFAIK, you can create another window in the Win32 API just like you did for the first one, each having their own message loop.
Why can't the second window be a child window ?
~RaGE();
|
|
|
|
|
The program is a SDI, it will be used to create, edit, and administer tests to students. There is a main form, which basically provides a menu of what is to be done, ie. create a new test. These tests will either be printed out, or taken on the computer, and will only consist of short answer or multiple choice questions.
So, in the end, it will need
a) the main form
b) a form to create the test file
c) a form to design the test
d) a form to take the test
e) a results form
and the list goes on.
The second window can't be a child window because the first form will be disapeared while any other forms are active.
I figured that the second window would be made the same way, but I saw potential problems with the
while(GetMessage(&Msg, NULL, 0, 0) > 0)
{
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
|
|
|
|
|
I just finished trying it out, and it works.
Just declaring a new WNDCLASSEX object, with the same hInstance, the same MSG, and a new WindowProc... and it worked fine.
|
|
|
|
|
In this day when .NET is about to be out with its second version, and MFC has been around for some 10 years, I can't fathom anyone using the Win32 API to do Windows programming!
Nevertheless, it's a good learning experience. Good luck!
Regards,
Alvaro
The world is a dangerous place, not because of those who do evil, but because of those who look on and do nothing. -- Albert Einstein
|
|
|
|
|
too much bloat for games and such
Jason Henderson "You must be the change you wish to see in the world." - Gandhi
articles profile
|
|
|
|
|
Yeah, for games sure. But he's just doing a bunch of data entry forms.
Regards,
Alvaro
The world is a dangerous place, not because of those who do evil, but because of those who look on and do nothing. -- Albert Einstein
|
|
|
|
|
I want my messagebox to automatically vanish after a few seconds....I will probably be emitting it in my View class...ANy hints? Thanks
Appreciate your help,
ns
|
|
|
|
|
Use this and give it a callback procedure.
int MessageBoxIndirect(
LPMSGBOXPARAMS lpMsgBoxParams // address of structure for message
// box parameters
);
Then you can just fire a message to the box when you are finished and close the dialog when you recieve that message.
OR,
use the same creation method, but in the WM_CREATE, start a timer and in your callback when you handle the WM_TIMER, you can just kill the dialog.
Hope this helps!
Dan Willis
|
|
|
|
|
The best way is to not use a standard MessageBox but your own dialog box. Inside it you can add a timer to close it after a certain amount of time.
I recommend that you also let the user know that in 10, 9, 8, ... the dialog box will close.
Regards,
Alvaro
The world is a dangerous place, not because of those who do evil, but because of those who look on and do nothing. -- Albert Einstein
|
|
|
|
|
Okay....this I can do! Off to the MSDN to look up SetTimer etc...
Appreciate your help,
ns
|
|
|
|
|
|
Thanks so very much! I didnt know where in CP to look for info on the messagebox and just seraching the keyword "messagebox" brought back a ton of .NET articles...whats with that!
Anyways, it looks perfect, except I am hoping its not modal.....so if they dont get rid of it, they shoud still be able to do things....I have to download your src and see. MAny thanks again!
Appreciate your help,
ns
|
|
|
|
|
I dont have vc 7 on this machine.....can I convert your sln to a dsw somehow?
Appreciate your help,
ns
|
|
|
|
|
|
I bookmarked it....
Appreciate your help,
ns
|
|
|
|
|
Is there a way to call this function and have it not "Beep" ?
Dan Willis
|
|
|
|