|
Ok, since I'm compiling only unicode I stuck with the wcs commands (Unicode is required for this, I'm not ever going to recompile it in MBCS). If there's a good reason for me to use the _TCHAR and _tcs commands instead, please tell me
The code DOES work now with the compare calls and the not writing back after uppercasing, but the 1-letter-extension problem still remains for some reason, after a one-letter extension it adds a 135-char... I don't get why...
As for the delete[]s, what to do in such a case if I want to RETURN the FileExt? I can't delete it before the return. And also, what to do with static variables? I assume I can't delete those either...
Thanks,
- Fahr
|
|
|
|
|
You have a couple of problems. First, the correct type for Unicode characters is WCHAR (yeah, it's the same thing as unsigned short due to a typedef, but using WCHAR will make the code easily readable by others). Then you're comparing strings with == which is not correct for C-style strings.
There's already an API for finding the extension, then once you have that use _wcsicmp() to do case-insensitive comparison.
int LookAtExt(LPCWSTR wszFilename)
{
LPCWSTR wszExt = PathFindExtension ( wszFilename );
if ( 0 == _wcsicmp ( wszExt, L".U" ) || 0 == _wcsicmp ( wszExt, L".DLL" ) )
return 1;
else if ( 0 == _wcsicmp ( wszExt, L".UNR" ) )
return 2;
else
return 3;
} You can also use a string wrapper class like wstring or CString (which has a handy CompareNoCase() method) to make the code a little neater.
--Mike--
When 900 years old you reach, look as good you will not. Hmm.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
PathFindExtension results in:
error LNK2001: unresolved external symbol __imp__PathFindExtensionW@4
I DO have shlwapi.h in my includes...
- Fahr
|
|
|
|
|
|
OK! That worked! Thanks a lot
It saves a lot of trouble of getting it myself, plus the weird trailing char error is no longer there
Also, you suggested the use of L"", while I use _T(""), a quick look in the TCHAR.h gave me the idea that _T("") is defined as L""... So what IS the actual difference? If any...
- Fahr
|
|
|
|
|
Use the TCHAR macros (including _T ) when you want to make ANSI and Unicode builds from the same code. Since you said you only need to make a Unicode build, you can go ahead and use L"" to make Unicode literals.
See my article on Win32 Character Encodings[^] for the full scoop.
--Mike--
When 900 years old you reach, look as good you will not. Hmm.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Well, that article does shed light on a lot of issues, thanks a lot
I actually DO need the DLL to run under Windows 98, if I use only unicode it wont work then I guess? I didn't quite realise that...
So what do I do now? Change all my L""s back to _T("")s and all my WCHAR*s to TCHAR*s?
Will that do the trick? And do I need to build 2 different DLLs for WinNT and Win9x??
- Fahr
|
|
|
|
|
Fahr wrote:
I actually DO need the DLL to run under Windows 98, if I use only unicode it wont work then I guess?
Right. You can use Unicode strings in 98, however you can't call Unicode APIs because they are not implemented. So yeah, you'll need to change your wcsxxx() calls to their _tcsxxx() equivalents, and use _T around literals. The string article covers this topic and why the TCHAR system is necessary.
It sounds like you're not using any NT-specific features, so you can just build an MBCS build of your code and use that on NT. Again, see the string article for the full story.
--Mike--
When 900 years old you reach, look as good you will not. Hmm.
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
yeah, I changed all it around...
problem is tho, as soon as I change UNICODE,_UNICODE to _MBCS, I get about 5 unresolved externals...
I'm using the DLL for native coding with Unreal Script, the script can call to the DLL and uses the core and engine of the game for game-specific functions, apperently those only support unicode...
Which is terribly odd, cuz the game runs on ANY windows...
- Fahr
|
|
|
|
|
How to find the Network speed (without PDH)?
Thanx
|
|
|
|
|
You mean, how to understand what the 'net connection is without a PhD? You don't.
No, seriously, your question also get the answer "you don't". Actually, it's worse, and so heavily depending on OS versions that you don't want to go there. Better ask (UI) the user what line-speed it think it has and work your way from there.
|
|
|
|
|
I want to execute a program (by the code) without having a exe file on the disk, but the file is on the memory.
|
|
|
|
|
Perhaps you could explain why you want to do this? If not, you'll probably be seen as another "virus writer wannabe" by anyone reading your question.
|
|
|
|
|
Dont be afraid.
We wrote a program that do some checks before it activate it self to be sure that it wasent copied illegally.
but we dont want that someone will find the place in the assembler code where the checks is being check in jump over it.
so we want to use this to prevent the problem.
|
|
|
|
|
Hi !
I have a small problem that I cannot figure out, when I add for example a menu to an MFC project and then type in the id in the property list "ID_VIEW_MYWINDOW" for example, everything look's fine but the value of ID_VIEW_MYWINDOW is zero (0), so to make it work I have to edit the resource.h file and change it to a working value myself, this happens all the time, both with old VC 6 projects converted to VS.NET and new projects.
Am I the only one with this problem ? (I have the same problem on two different computers).
Any ideas on what's going on would be helpful here.
|
|
|
|
|
Why does this control flicker so much? Is there anyway to get rid of the flicker?
Does MSKB address this issue? I've noticed many apps use this control (IWebBrowser2 anyways) and many if not all flicker except...outlook and IE.
Thanks
"Two wrongs don't make a right, but three lefts do!" - Alex Barylski
|
|
|
|
|
Hi,
Another problem..
I want to have a modeless dialog that will close if it loses focus. This dialog is open from another dialog. So in a dialog a have a button that does this OnClick:
CAnotherDialog *newDlg;
newDlg = new CAnotherDialog(this);
if (newDlg != NULL) {
BOOL ret = newDlg->Create(IDD_SOMEDIALOG,this);
newDlg->ShowWindow(SW_SHOW);
}
In CAnotherDialog a have a overrided the method OnKillFocus and declared ON_WM_KILLFOCUS() in the message map but this method gets executed when I close the dialog, not when it loses focus.
Thanks!
-----
We are what we repeatedly do. Excellence, then, is not an act, but a habit.
|
|
|
|
|
Try handling the WM_ACTIVATE message instead. The dialog usually doesn't have the focus; one of its child controls has it. I used this method on a project with some automated popups in a touch screen application. Touching 'away' from the popup caused it to close automatically.
Software Zen: delete this;
|
|
|
|
|
Thanks! It works.
If someone else needs this, the function looks like this:
void CMyDialog::OnActivate(UINT nState,CWnd *pWndOther, BOOL bMinimized) {
if (nState == WA_INACTIVE)
CDialog::OnCancel();
}
-----
We are what we repeatedly do. Excellence, then, is not an act, but a habit.
|
|
|
|
|
happy new year, all!
don't play ur C++ today, take a rest!
includeh10
|
|
|
|
|
Happy new year!
I'm still playing today.
-----
We are what we repeatedly do. Excellence, then, is not an act, but a habit.
|
|
|
|
|
Hi folks,
I'm gonna build a GUI which works with XML for a class Project. How can I go about it? Any Pointers are welcome.
|
|
|
|
|
Do you mean use XML to drive gui creation? Or gui manipulation on the fly with XML? Or do you mean manipulate XML from a gui?
Either way one you'll probably want to use some kind of XML parser. You mentioned Visual C++ so I'm assuming you're talking about VC++ 6.0. If that's the case then there are plenty of XML parsers you could use. Do a google search for MSXML4.0 or Xerces. There's some others but I can't remember them right now. You may also want to check W3C for XML parsers and tutorials. I personally use MSXML4.0 though some people snicker at the idea. It suits my needs fine.
If it's the GUI part you need help with there are plenty of articles here on CodeProject that can give you a good start.;)
nay
|
|
|
|
|
Anonymous wrote:
I'm gonna build a GUI which works with XML for a class Project. How can I go about it? Any Pointers are welcome
If you are allowed to, use the Xml classes from the .NET framework. Not only it's an incredible product quality/price ratio, it also makes you take your distance from the bullish msxml parser (former MS Xml sdk).
In addition, you can fill the .NET tabular datagrid control with Xml content, from/to flat files or databases. This can shorten the dev time.
|
|
|
|
|
See http://www.ltpb.8m.com/tutorial[^] I have written many articles on using XML and with VC++.
-Steven
CP Addict
By reading this message you are held fully responsible for any of the mispelln's or grammer, issues, found on, codeproject.com.
For those who were wondering, actual (Linux) Penguins were harmed in creating this message.
|
|
|
|