|
Hello,
I want to search all drives for particular filetypes. I know how to search all the directorys on a drive, but I don't know how to get a list of all the drives availeble on the computer (I don't need a list of network drives)?
many thanks in advance
|
|
|
|
|
Check out GetLogicalDrives()[^].
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
thanks
|
|
|
|
|
Hello!
I am writing a program which needs to read the data file (in plain text format) to the memory structure (array).
Currently, I am reading the text data file one line at a time using CStdioFile and CString. For each line in the CString, from left to right, decode each segment (separated by ,) into another CString and then atof it to a real number. This is very slow and read in a 600K file will needs 10 seconds or more.
How can I do it faster using C++? (I don't want to mix C in it.)
Thanks a lot.
The data file looks like:
134.235, 235.23, 2353.25, 252.23, 2356.247, .....
234.235, 635.23, 6233.25, 772.23, 8356.247, .....
534.235, 895.23, 3553.25, 243.23, 7856.247, .....
I am using a data structure similar to a 2D array to hold it.
|
|
|
|
|
Kevein wrote:
This is very slow and read in a 600K file will needs 10 seconds or more.
That is redicously slow. It should be < 1 sec on a reasonably machine. I'd look at using a Memory Mapped File and possibly STL. With CStdioFile and CString there is a lot of waisted overhead moving stuff around in memory, allocating memory etc.
Have a look at the pugXml article here on CP http://www.codeproject.com/soap/pugxml.asp[^] which shows an example of using MMF. I can open and parse a 10M XML file on my slow old 550Mhz PC in approx .5 sec using this code.
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
Why not mix with C, the CStdioFile::ReadString() calls _fgetts() (a C function!)...
Is the data on a single line or are there any cr/lf pairs?
I'll continue assuming that there are not!
Since _fgetts() reads the data character by character this solution works faster and it saves you the time of splitting the strings!
int nRead = 0; // number of bytes read
char cBuf = 0; // charBuffer
char szNumber[100]; // the string to use with atof
for(int nIndex = 0;;nIndex++)
{
::ReadFile((HANDLE)CStdioFile::m_hFile, &cBuf, 1, &nRead, NULL)
if(cBuf == EOF)
break;
if(cBuf == ',')
{
szNumber[nIndex] = '\0';
// add to your 2d array here with atof()
}
else
szNumber[nIndex] = cBuf;
}
this should work faster!
good luck.
|
|
|
|
|
Hello all
I created a MFC Dialog based project. At the time of creating the project I forgot to select "Context Sensitive help". Now I want to build a help file for my project. Is there any way to enable it for the existing project.
If any one knows how to do it, please help.
Thanks for your help
Hari.
|
|
|
|
|
I have this Help tutorial that explains how to solve your problem. I am just going to paste it here. I have never used these concepts because I never forgot to check "Context Sensitive help".
Manually Add the Context Hooks
If you already have a program and need to add help, you can manually edit the files to create the necessary
hooks.
To add context sensitive help manually:
1. Add the necessary message map entries in the message map of the Main Frame class. If you created the
program with the MFC App Wizard and specified that you wanted context help, these items should already
be in the file.
ON_COMMAND(ID_HELP_FINDER, CMDIFrameWnd::OnHelpFinder)
ON_COMMAND(ID_HELP, CMDIFrameWnd::OnHelp)
ON_COMMAND(ID_CONTEXT_HELP, CMDIFrameWnd::OnContextHelp)
ON_COMMAND(ID_DEFAULT_HELP, CMDIFrameWnd::OnHelpFinder)
2. Copy the What's This? Help icon into a button on your toolbar. This icon is available as a bitmap in
C:\Program Files\Microsoft Visual Studio\Common\Graphics\Bitmaps\OffCtlBr\Small\Color\help.bmp.
3. Assign ID_CONTEXT_HELP to the What's This? Help button.
Note:
• This creates the same basic hooks in the program as the App Wizard, but does not generate a framework
help file or the .hm file with the topic ID mapping. You will need to create a list of IDs for the help author
to use.
Override the Default Context Help Behavior
The default WinHelp call made from the hooks automatically created by the App Wizard opens each help topic
in the main WinHelp window. Unfortunately the current recommended behavior is:
• Control level help is opened in a popup.
• Window level help is opened in a secondary window.
To create these conditions, you must override the default functions.
To create currently recommended behavior:
1. In the Main Frame class, create an OnHelpInfo function using the Class Wizard:
BOOL CMainFrame::OnHelpInfo(HELPINFO* pHelpInfo)
{
return TRUE;
}
This effectively disables the function, and is necessary because, in combination with the next override, all
topics accessed through the F1 key will be called twice. Unfortunately you cannot use the OnHelpInfo
function in the Main Frame since (unlike in dialog boxes) it is triggered only by the F1 key and not by Shift-
F1 or the key.
2. In the Main Frame class, create a WinHelp function using the Class Wizard:
void CMainFrame::WinHelp(DWORD dwData, UINT nCmd)
{
CWinApp* theApp = AfxGetApp();
CString helpFilePath = theApp->m_pszHelpFilePath;
switch ( dwData ) {
case HIDR_MAINFRAME:
case HIDR_MFCWIZTYPE:
case HIDD_ABOUTBOX:
case HIDD_TESTDLG:
helpFilePath = helpFilePath + ">second";
::WinHelp(m_hWnd, helpFilePath, HELP_CONTEXT, dwData);
break;
case WHATEVER
...
break;
default:
::WinHelp(m_hWnd, helpFilePath, HELP_CONTEXTPOPUP, dwData);
break; }
}
Tips:
• It is often easier to create a separate function or class to process the help calls and open topics in the
correct window. This can be part of the main program or can be created as a separate DLL. The main
advantage of a DLL is that it can be called from other programs if necessary.
• If you want the help author to be able to control the help file and window called by this function, class, or
DLL, put the help file and window definitions in an INI file (you can use the topic number as the key) and
look them up before calling Help. If you include the help type as an INI file entry you can easily call
multiple types of user assistance from the same program.
// Afterall, I realized that even my comment lines have bugs
When one cannot invent, one must at least improve (in bed).-My latest fortune cookie
|
|
|
|
|
During a large edit on my project; adding lots of static text to a new dialog. I used a lot of cut/paste and
some of the paste went off the form.
The long story is that (well I think) that the resource data for the project has got a bit out of step and the current
situation is to go in directly (resource.h and the .rc files) to add additional static text fields.
This is because any attempt to place ANY control on the dialog is just ignored; i.e. nothing happens
Are they any tools to check/help check out this type of problem? I did double click on some of the
labels and created an event handle (unwanted) but now removed them.
Are they a problem with the IDE such that some setting has been set in error.
Are they any way to regain the IDE back online; i.e able to use the GUI to add aditional controls.
I think that the problem is reated to the resource.h file and the .rc file.
In the resource.h file:-
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 143
#define _APS_NEXT_COMMAND_VALUE 32771 <---- ? how to check
#define _APS_NEXT_CONTROL_VALUE 1114
#define _APS_NEXT_SYMED_VALUE 104
#endif
#endif
I see the use of all apart from _APS_NEXT_COMMAND_VALUE
If I could check this value then I may sort out the problem.
Note: I have this happen in both Visual C++ (Version 6) and on Visual Studio .Net; my current project.
Regards,
Graham.
PS Everyone says delete the dialog and re-do it! They must be a better way.
grahamfff
|
|
|
|
|
Hi!
I wonder if there is a way to get the path to the directory where the program exe file is located. When I use GetCurrentDirectory it works if I start the program with the exe file, but not if I dubble-click a saved file. Do I have to use the registry key. The thing is that other programs don't seem to do that. Is there not a function for this?
Thanx
Martin_j
|
|
|
|
|
MFC:
char szFileName[ _MAX_PATH ];
GetModuleFileName( AfxGetInstanceHandle(), szFileName, sizeof(szFileName) );
char szDrive[ _MAX_DRIVE ];
char szDir[ _MAX_DIR ];
_splitpath( szFileName, szDrive, szDir, NULL, NULL );
CString strTheFolderYouWant;
strTheFolderYouWant.Format( "%s%s", szDrive, szDir ); Win32:
char szFileName[ _MAX_PATH ];
GetModuleFileName( GetModuleHandle(NULL), szFileName, sizeof(szFileName) );
char szDrive[ _MAX_DRIVE ];
char szDir[ _MAX_DIR ];
_splitpath( szFileName, szDrive, szDir, NULL, NULL );
char szTheFolderYouWant[ _MAX_PATH ];
sprintf( szTheFolderYouWant, "%s%s", szDrive, szDir );
|
|
|
|
|
Wow! I always implemented my own _splitpath routine. I had no idea that there was a function that does that. Thank you (even though this is not my post).
// Afterall, I realized that even my comment lines have bugs
When one cannot invent, one must at least improve (in bed).-My latest fortune cookie
|
|
|
|
|
Thanx! That really helped.
Martin_j
|
|
|
|
|
Or try the following to avoid _splitpath:
TCHAR tcFileName[ _MAX_PATH ] = {0};
::GetModuleFileName( GetModuleHandle(NULL), tcFileName, sizeof(tcFileName) / sizeof( tcFileName[ 0 ] ) );
LPTSTR lpszFileName = ::PathFindFileName( tcFileName );
if ( ( NULL != lpszFileName )
&& ( tcFileName != lpszFileName )
{
*lpszFileName = 0;
}
tcFileName now contains the directory.
Jens
|
|
|
|
|
In my project, i use a party HTML GUI. I included the pages as resources in the exe. I then let the HTML window navigate to res://NameOfApp.exe/305 . This works correctly. However, if i want to include an image (gif image sequence in my case), i can't get it done this way because there's no way to tell IE that the file i feed it is a GIF file , because it doesn't have an extension and there's no way i can use an extension for the file because it's a resource.
Is there a way in HTML to tell the browser that the file is in fact a GIF file?
|
|
|
|
|
Give it a string name instead of a numeric ID. That way you can navigate to res://NameOfApp.exe/MYFILE.GIF
--Mike--
"Big handwavy generalizations made from a position of deep ignorance is one of the biggest wastes of time on the net today.
-- Joel Spolsky
Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber
|
|
|
|
|
Still can't get this right....the res:// thingy only works for HTML pages and not for any image type . What am I doing wrong? Showing you the code isn't really usefull because there isn't much to show...
|
|
|
|
|
I inserted a JPG HTML resource in a DLL, and I can show that picture in IE with this URL:
res://C:\utils\dirclean.dll/ALY.JPG
I found the right combo of slashes and backslashes thru trial-and-error
--Mike--
"Big handwavy generalizations made from a position of deep ignorance is one of the biggest wastes of time on the net today.
-- Joel Spolsky
Ericahist | Homepage | RightClick-Encrypt | 1ClickPicGrabber
|
|
|
|
|
I used the exact same combo already but it just doesnt't work. Maybe it's the point that I use an exe instead of a DLL. You think that's what's wrong? If that's what i need to do (Use a DLL) then could you maybe give me a link to a project that uses resource DLL's in different languages (Like MSN messenger)?
Thanks for your awnser
|
|
|
|
|
Hello,
I have a dialog-based application which supports resizing of its windows.
The resizing works very well, it's just a visual thing I am looking for: the resizing "image" on the right bottom.
For example open Internet Explorer and have a look bottom right. There are diagonal 3D lines, overlapping the status bar, which show that the dialog is resizable.
Do you know how to show these diagonal 3D lines?
Thanks
-Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
|
|
|
|
|
In your WM_PAINT handler, do this:
DrawFrameControl(hdc,rect,DFC_SCROLL,DFCS_SCROLLSIZEGRIP);
rect should be the rectangle where you want the frame control to be, and hdc should be the HDC of your window.
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
Hmm, I somehow can't get it working... Do you have a sample source snippet?
Thanks
-Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
|
|
|
|
|
The frame control is drawn now (the background isn't erased correctly, so if you have a source snippet send it to me, I am not that GUI expert ), but the background of the frame control is always the standard gray. The problem is now that my application uses a custom background color...
I tried to change the background color for the frame control using dc.SetBkColor and/or dc.SetBkMode(TRANSPARENT), but nothing worked, the gray background is drawn independently of what I set as DC background...
How can I make the frame control background drawn as the same as my main dialog background color?
PS: Going to now, so thanks in advance
-Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
|
|
|
|
|
You can't. But, I have a hint for if you want to draw your own gripper - the gripper glyphs are found in the Marlett font.
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
Hmm, I found the font and the symbols, but when I draw them they are only black lines instead of the 3D look. It seems I have to combine symbol 'o' (=white) and symbol 'p' (=dark gray) to make the 3D look
I've done it another way now: I've created an icon that looks like the 3D gripper Much easier
Anyway, thanks for your help
-Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
|
|
|
|
|