|
|
Hello everyone,
I am searching the way to find for in archives and folders recursively.
You can say me the optimal way to do it?
Thanks!
navisoft
www.latindevelopers.com
|
|
|
|
|
Take a look at this article: http://www.codeproject.com/file/fileglob.asp[^], it implements exactly what you want and more.
Hope that helps!
Sincerely,
Alexander Wiseman
Est melior esse quam videri
It is better to be than to seem
|
|
|
|
|
you can do a function like this
int findfiles()
{
...
findfirstfile(*.*)
if file=a directory
findfile(directory)
}
gabby
|
|
|
|
|
Hai,
I'm working on win32 vc++.I want to get the user logon ID from the system and display it in my dialog(probably in a textbox).I dont know how to do that.
Can anyone help pls.
Thanks a lot in advance.
|
|
|
|
|
Hi,
You can obtain the current username writing follow code:
DWORD userNameCharCount = 255;
TCHAR userName[255];
if( !GetUserName( userName, &userNameCharCount) ){
// error!
}
CString str = userName;
GetDlgItem(IDC_YOUREDIT_CTRL)->SetWindowText(str);
navisoft
www.latindevelopers.com
|
|
|
|
|
I am trying to create an OpenGL MDI application using Doc/View architecture.
When the ID_FILE_NEW is handled, a child window with the correct openGL rendered scene appears. however when the ID_FILE_OPEN is handled by CWinApp:: OnFileOpen in the application, a 'VERIFY' in the following bit of code called causes an error. i am unable to determine why it occurs.
BOOL CDocManager::DoPromptFileName(CString& fileName, UINT nIDSTitle, DWORD lFlags, BOOL bOpenFileDialog, CDocTemplate* pTemplate)
{
CFileDialog dlgFile(bOpenFileDialog);
CString title;
VERIFY(title.LoadString(nIDSTitle));
any help would be much appreciated.
thanks.
|
|
|
|
|
LoadString() has failed to load the string resource with the ID contained in nIDSTitle. Chances are you do not have that string in your string table.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
Run your code in debug mode, and step through all function calls. Stepping allows you to see the parameters passed to the function, and simultaneously allows you to see the string table entries. If you encounter a situation where an invalid ID is passed to the function, try tracing back to see why it gets passed.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Thanks.
i hadn't included "afxres.rc" in the resource file - that was causing the problem. i had included only "afxres.h" earlier.
the trouble i am having now is that the child windows don't have a title. the resource string is fine - i used it in another program, it works ok.
any comments would be most appreciated.
thanks.
|
|
|
|
|
If a file has been mapped with MapViewOfFile, will the offsets in memory correspond to the ones in the disk. For example if I try to access the contents at file offset 0x100 in the disk, after I map the file would I still be using offset 0x100 or will the memory alignment make the offset change.
// Afterall, I realized that even my comment lines have bugs
If the sun were to blow up, it would take us 7-8 minutes to realize it.
|
|
|
|
|
Toni78 wrote:
will the offsets in memory correspond to the ones in the disk
Yes, they will. However, ensure that either the whole file has been mapped, or the relevant portion that you want to access, has been mapped.
Note that the "offset" must be added to the address returned by MapViewOfFile(). Optionally, MapViewOfFileEx() allows you to specify your own base address where the file will be "loaded".
Memory alignment has to be taken into consideration when
the file was opened with FILE_FLAG_NO_BUFFERING in the CreateFile() call.
Bikram Singh
|
|
|
|
|
Thank you for your help.
After I posted the question and I got no reply, I realized that I could test this by myself by loading the file and doing a byte compare with the file in the disk . At the end the files were identical so apparently there were no memory alignment issues. But I wasn't aware about FILE_FLAG_NO_BUFFERING . Either way, thank you again.
// Afterall, I realized that even my comment lines have bugs
If the sun were to blow up, it would take us 7-8 minutes to realize it.
|
|
|
|
|
Hi All, was hoping I mightbe able to get some help. I have been looking at a few of the clipboard examples on this site and made this code based on some of it:
if(capEditCopy(captureWindow)) //Capture frame from video stream to clipboard
{
if ( OpenClipboard(NULL) )
{
if (!IsClipboardFormatAvailable(CF_BITMAP))
return;
//Get the clipboard data
HBITMAP handle = (HBITMAP)GetClipboardData(CF_BITMAP);
CBitmap * bm = CBitmap::FromHandle(handle);
CSize sz = bm->GetBitmapDimension();
long foo = sz.cx;
CloseClipboard();
}
The long foo was merely created to check whether the bitmap was defined properly, the problem is, foo always comes back as zero. Why is this? Was the bitmap ever created? My aim here is to merely get a bitmap so that I can manipulate some of the pixel values.
Any help would be greatly appreciated. Thanks in advance.
Micheal
|
|
|
|
|
RTFM[^]
[quote]
CBitmap::GetBitmapDimension
CSize GetBitmapDimension( ) const;
Return Value
The width and height of the bitmap, measured in 0.1-millimeter units. The height is in the cy member of the CSize object, and the width is in the cx member. If the bitmap width and height have not been set by using SetBitmapDimension, the return value is 0.
Remarks
Returns the width and height of the bitmap. The height and width are assumed to have been set previously by using the SetBitmapDimension member function.
CBitmap Overview | Class Members | Hierarchy Chart
See Also CBitmap::SetBitmapDimension
[/quote]
Use a BITMAP structure filled with CBitmap::GetBitmap(BITMAP *) to get the bitmaps dimensions.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
I am trying to use CDOSYS in a c++ application to send some emails.
I have used #import to get the libraries and everything seems to be working ok except that the mail messages get stuck in inetpub\mailroot\queue.
Any ideas how to find out what the problem is?
Mike
|
|
|
|
|
Could this be an issue with the IIS ? A misconfiguration somewhere ? Can you send normal mail messages using an application such as Outlook Express ?
The CDOSYS API is pretty straightforward, so the errors should be limited to missing sender/recipent or other mail header info. One option here is to see the IIS logs for any tips. Usually when mails are stuck in the queue there's a reason for it, and it's logged. If it's not, you should increase the logging sensitivity (what gets logged) so that everything is written there. Then try again and see if any errors occur.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
I would like to implement a class that will deallocate itself if something in the constractor fails. Something to work like this
class MyClass
{
public:
MyClass(char * filenm) {/* if filenm does not exist the class constuction fails*/};
~MyClass() {};
}
MyClass *mine = new MyClass("filename");
if(!mine)return 0;
....
This should be something similar to how ifstream functions. I tried to look at its code but did not manage to understand it.
Is there a way that I can make this work?
Thanks a lot
Michael
|
|
|
|
|
1. The clean and legal way in C++ to handle a failing constructor is to throw an exception
2. If your construtor throws an exception, C++ will:
- free the memory allocated for the object itself (if the allocation was dynamic)
- call the desctructors of all members and base classes (that were initialized)
It will NOT, however, call the destructor of the object that failed the construction. Since the object was not constructed completely, it would be dangerous to call the destructor.
we are here to help each other get through this thing, whatever it is Vonnegut jr.
sighist || Agile Programming | doxygen
|
|
|
|
|
Exceptions are your friends!
I suggest, do what peter says.
However, if you do want to try:
Use a function to return the object instead of doing it with "new". Such a concept is usually called a "Class Factory" (concept from COM), whose sole purpose is to create and return an instance of a class.
void *CreateClassAA(string a)
{
if(a == "")
return 0;
else
.............
}
Bikram Singh
|
|
|
|
|
Yes this is a good idea.
But how is it done in ifstream? Does it really work fine?!
Thanks
Michael
|
|
|
|
|
hi,
i have a dialog box with a static control. the problem is that when i try to use setbkcolor for the static control in oninitdialog of the dialog box, it does not produce any results. i have tried to use GetDC() for the static control to get the DC. and then tried to set the background color of the static control. can any one give me a solution?
regards,
kevin
|
|
|
|
|
|
using WM_CTLCOLOR causes problems in other parts of my code. is there any other solution?
|
|
|
|
|
It should not affect other parts of your code.
Here is a sample of my code.
HBRUSH CMyView::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CFormView::OnCtlColor(pDC, pWnd, nCtlColor);
INT nIDCtl = pWnd->GetDlgCtrlID();
switch(nIDCtl)
{
case IDC_STATIC_CTRL1:
{
pDC->SetBkColor(RGB(255, 255, 255));
CBrush br;
br.CreateSolidBrush(RGB(255, 255, 255));
hbr = (HBRUSH)br;
br.Detach();
}
break;
case IDC_STATIC_CTRL2:
....
....
case IDC_STATIC_CTRL3:
....
....
case IDC_STATIC_CTRL4:
....
....
}
return hbr;
}
|
|
|
|