|
Hi,
this should be quite an easy fix, I just don't know how.
I'm writing an internationalised program that has to store text in a file. I cannot for the life of me get the stl ifstream extractor to compile for UNICODE...
i.e. these do not work
TCHAR t[1024];
stream.getline(t,1024,'\n');
...
TCHAR t[1024];
stream >> t;
...
std::wstring w;
stream >> w;
but if I convert TCHAR to char the damn thing compiles. What am I missing? Surely something in the STL templates allow the reading of a double byte character from the stream.
Any pointers appreciated.
Matthew
|
|
|
|
|
Use wifstream , which is the instantiation of basic_ifstream for wchar_t (instead of char ). Better yet, define a macro of your own for selecting ifstream /wifstream the way TCHAR does.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
wicked, thanks. I never even knew wifstream was there.
I am very pleased indeed.
did I say thanks?
Matthew
|
|
|
|
|
I work in Windows 9x and Window 2000 environment, and I am developing a Win32/MFC application.
I got a question about the one of the "monitor properies" in Windows.
Remember ? When you are in Windows desktop, right click the mouse, and a pop-up menu shows. The last one is "Properties". And when you choose the "Property", there are 6 tabs. The 4th or 5th tab is "Effect". And, there is an item: "Show window contents while dragging".
Now, if I want to set this property ("Show window contents while dragging") in my win32/MFC application, is there any win32 or MFC API I can use in my program to do this ?
Thanks for your help !
|
|
|
|
|
It's just a registry setting, therefore you use the registry API.
--
Where are we going? And why am I in this handbasket?
|
|
|
|
|
>>It's just a registry setting, therefore you use the >>registry API.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Which registry API ? Could you explain more detail ?
Thanks a lot !
|
|
|
|
|
I found an API in MSDN: SystemParametersInfo(..),
but I still can not find any parameter that looks like the property(show window contents while dragging)..
|
|
|
|
|
The Registry Key which controls show contents of window while dragging is
Key: [HKEY_CURRENT_USER\Control Panel\Desktop]
Name: DragFullWindows
Type: REG_SZ (String Value)
Value: (0=disable, 1=enable)
You can use API RegOpenKey, RegCreateKey... in your app to check if it exists.
If so check the value and toggle it to your needs. If not create it.
Atul Dharne
#include "codeproject_users_experience_"
using namespace codeproject;
|
|
|
|
|
Call SystemParametersInfo():
SystemParametersInfo ( SPI_SETDRAGFULLWINDOWS, TRUE, 0, FALSE );
Change TRUE to FALSE to turn it off. (Messing with the user's settings w/o asking first is a Bad Thing, so don't do this w/o permission.)
--Mike--
http://home.inreach.com/mdunn/
"Not our fault we are intellectually superior to the rest of the office." -- Paul Watson in the Lounge, 12/12/2001
Sonork - 100.10414 AcidHelm
|
|
|
|
|
Hi,
Have hit the problem again of copying updated exe to the server, only to find some bright spark still has it open and has gone to lunch so the copy fails.
Now, having no access to the server, for the sake of argument, can someone point me in the right direction on how to get the info on who has a given file open from the server thru code?
Thx
Mark
|
|
|
|
|
If you have no access to the server, there is no way to know who has it open. Only the server knows that information.
--
Where are we going? And why am I in this handbasket?
|
|
|
|
|
Check out the WMI stuff here and on MSDN. Several of the WMI examples deal with network drives and open files.
Hope this helps,
Bill
|
|
|
|
|
Thx for the reply,
I can't find anything here on codeproject to do with WMI and the SDK I just downloaded makes me realise how 'stoopid' I am
Dont suppose I can prevail upon you to point me in a slightly more confined direction?
Mark
|
|
|
|
|
Sorry, I meant codeguru. Here is a good starting point.
http://www.codeguru.com/system/WMI_using.html
This is the Microsoft tutorial.
http://msdn.microsoft.com/downloads/default.asp?URL=/code/sample.asp?url=/msdn-files/027/001/574/msdncompositedoc.xml
The WMI SDK also contains many more examples. I had pretty goo luck using Google to find info.
WMI is a client server type arrangement. The server software is called a provider. Once you know what providers you need to use, you can do more specific searches on google.
My own project used the Win32_Processor provider. I put Win32_Processor and Loadpercentage into a Google.com query and got lots of links, some of which were useful.
Hope this helps,
Bill
|
|
|
|
|
Can anybody either
a) provide me with a C\C++ function that mimicks CString::Replace in functionality, or
b) explain in detail (i.e. step by step) how to do this myself?
I have tried for ages, but can;t get anything that works.
Thank you,
Russell McCurly
Hobbiest Programmer
|
|
|
|
|
can't offer code, but have a look at std::string, from the C++ standard library.. (#include <string>) - it has members such as find_first_of() and replace() that you should be able to use quite easily to perform the CString::Replace() functionality.
happy coding!
|
|
|
|
|
It's not a trivial task because the text being replaced may be larger or smaller (in length) than the text to replace it with. I recommend looking at CString::Replace's source code to get some ideas. Even better, use the debugger to step into the function to see it in action.
If you want, you may also post your source code and we'll try to spot the problems.
Regards,
Alvaro
|
|
|
|
|
I've been teaching myself C++ for the past couple months and I'm absolutely loving it. I'm attempting to learn classes right now and I'm writing my own little program. Here is the code:
#include
using namespace std;
class CLogin{
private:
char m_Username[15];
char m_Password[15];
char m_Usernames[2][9]={"John","Bob"};
public:
void getUsername(){
cout<<"Enter user name: ";
cin>>m_Username;
cout<<"You entered: "<
|
|
|
|
|
char m_Usernames[2][9]={"John","Bob"};
You can't initialize a member variable within a class declaration. You have to do that within a constructor or some other member function.
char m_Usernames[2][9];
HTH,
Jon Sagara
"There are lies, damned lies and statistics."
-- Mark Twain.
|
|
|
|
|
I'll have a go at it...
/************************************************\
* Class Definition *
\************************************************/
#include <<someheaderhere>>
using namespace std;
class CLogin{
private:
char m_Username[15];
char m_Password[15];
char m_UserNames[2][9];
// Can't do this here. Need to do this through a member function
// or a constructor
char m_Usernames[2][9]={"John","Bob"};
public:
CLogin() // Default Constructor
void getUsername();
};
/***************************************************\
* Class Implementation *
\***************************************************/
CLogin::CLogin()
{
m_Username[0] = ' ';
m_Password[0] = ' ';
m_UserNames[0][0] = {' ',' '};
}
void CLogin::getUsername()
{
cout<<"Enter user name: ";
cin>>m_Username;
cout<<"You entered: "<<m_username;
}
********************************************\
*="" program="" entry="" point="" *
\********************************************=""
int="" main(void){
clogin="" login;
login.getusername();
return(1);
}
it="" should="" be="" cleaned="" up="" enough="" now="" to="" allow="" you="" compile="" it.
you="" initialize="" your="" variables="" through="" the="" class="" constructor="" or="" another="" member="" function.="" take="" time="" learn="" about="" standard="" string="" class...="" you'll="" never="" use="" char="" array's="" again="" =""
good="" luck="" and="" happy="" programming="" =""
<b="">Paul Lyons
Do not go where the path may lead, go instead where there is no path and leave a trail.
- Ralph Waldo Emerson
|
|
|
|
|
You can initialize fundamental data types in your class interface..
(a'cordin to the new C++ std + the compiler must support)
class CNewStd
{
private:
unsigned int m_nCount = int(8); //or use int() for zero initialization
public:
.
.
};
Atul Dharne
___First Law of Security___
1. Don't buy a computer...
|
|
|
|
|
pliz help me...
i want to get the text string from the focused editbox of focused application...
how can i do it?
|
|
|
|
|
GetWindowText ? I believe if you have the HWND of the app, you can get the HWND of the focused control.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|
|
ye, i have the HWND of the app...
but now how can i get HWND of the control?
|
|
|
|
|
It it has the focus, you can call GetFocus, I presume this will return the control that has the focus, not the parent window. You don't even need the windows HWND.
If I'm wrong, you can iterate looking for the control with focus with GetNextDlgTabItem.
Christian
After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001
Sonork ID 100.10002:MeanManOzI live in Bob's HungOut now
|
|
|
|