|
'W' is supposed to be a wide character so use L'W'
You may be right
I may be crazy
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|
|
As a side note, your loop limits are wrong, you should use
for (n=11; n>=0; n--)
or, better
for (n=wcslen(S)-1; n>=0; n--)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
If this is your actual code, you aren't getting that error. S[n] returns a wchar_t, not a LPWSTR. 'W' doesn't need to be L'W' since it will auto-promote to wchar_t.
(Plus, for(n should be for(int n .)
|
|
|
|
|
Joe Woodbury wrote: 'W' doesn't need to be L'W' since it will auto-promote to wchar_t.
That should not be true.
It was true with old C++ version, where the wchar_t was not an independent type, and was just a typedef for "unsigned short", and "char" autopromote into "short" and become "unsigned".
In more modern versions, wchar_t can be set up as an independent type with a compiler switch and -now- it becomes a default by standard.
Autopromotion of char-s into wchar-t must not happen, since the "encoding scheme" used in strings may not fit: All negative chars (above 127) are not ASCII and hence may have different meaning if ANSI (depending on the codepage) or UTF (can be UTF-8).
That said, char to wchar_t is not a one-to-one arithmetic conversion. You may have four chars going into a single or a pair of wchar_t (think to UTF-8 to UTF-16 chinese).
2 bugs found.
> recompile ...
65534 bugs found.
|
|
|
|
|
Good to know, but weird, in my opinion.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
That's was what i though when that differentiation was introduced.
But it saved me lot of time form char-type mismatching in strings!
The "werid" thing is that C++ is still taking the old C idea of "char are just numbers" and strings don't exist (there are character arrays and string manipulation functions).
Than wchar_t was introduced, and a type semantic was applied to it.
It would be more correct -nowadays- the case that even char should not have number semantic and a different type (may be byte and unsigned byte , or short short int ) should be introduced to represent small integers)
I also wander why C and C++ standard are insisting with all those sort of short , long , long long , long long long , etc. instead of simply define integers as int_x where x is the number of bits (MS does it, but it's not "standard").
Then there might be char_x , incompatible with int_x unless of explicit conversions and functions.
2 bugs found.
> recompile ...
65534 bugs found.
|
|
|
|
|
Well, after 'initial shock' I think you are actually right.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
This is more funny I don't know if it's related to the new standards or if not.
My program has a linked list data structure in C++.
So...
class Whatever
{
public:
LPWSTR *Info;
};
is my basic data structure.
I store info along the way from a ComboBox in a Whatever data structure.
Eventually I want to process several of Info and divide them in several Strings.
if (Test->Info[n] == L'/')
{
}
I end up getting these errors.
1>main.cpp(686): error C2446: '==' : no conversion from 'int' to 'LPWSTR'
1> Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
1>main.cpp(686): error C2040: '==' : 'LPWSTR' differs in levels of indirection from 'int'
However if I address LPWSTR directly not through the C++ class data structure everything goes smooth as silk.
|
|
|
|
|
Try to change:
Fareed Rizkalla wrote: class Whatever
{
public:
LPWSTR *Info;
};
...to :
class Whatever
{
public:
LPWSTR pInfo;
};
virtual void BeHappy() = 0;
|
|
|
|
|
Like I said a ComboBox adds information into Info so their is buffering problem!
So Info size has to be pointer to be sized for the ComboBox text.
|
|
|
|
|
LPWSTR* Info;
Info[n];
Info[n][m];
virtual void BeHappy() = 0;
|
|
|
|
|
But it's not a 2 dimensional array.
int **cha;
cha = new int[10];
for (int r = 0; r < 10; r++)
{
cha[r] = new int[10];
}
So how do you target a character I have to pass 2 locations to Info.
|
|
|
|
|
Yes, I was pointing out what was, not what should be and disagree with you anyway on that point.
char and wchar_t ultimately are just numbers and have no intrinsic meaning on their own--the compiler has no idea what encoding scheme you are using. Is it UTF-16BE, UTF-16LE? Even char doesn't imply what the code page is.
|
|
|
|
|
I want to use multiThread to read and write database,but I do not how how to prevent the thread from reading db again and again,
for example, I want use Thread1 to read record 1 - 100,and use Thread2 to read record 101-200,but I don`t know how to control different threads to read different data?
|
|
|
|
|
Thread synchronization is a big topic. Have a look at MSDN [^].
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
caiguosen wrote: ...but I don`t know how to control different threads to read different data?
Is thread 2 not supposed to read until thread 1 finishes?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
they can read together,but the content which thread one reads can not be read by thread2.
there will be many threads, just like client/server mode,
but how can i control these threads in order to let them read different data from the same database.
|
|
|
|
|
I've never tried anything like this, but my first attempt would be to set some sort of filter (i.e., WHERE clause), like:
SELECT * FROM table WHERE 1 <= rownum AND rownum <= 100
SELECT * FROM table WHERE 101 <= rownum AND rownum <= 200
SELECT * FROM table WHERE 201 <= rownum AND rownum <= 300 Does that sound plausible?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
I have a CFormView where I want to display an image and show some buttons over the image. I get the device context for the view, create a compatible bitmap, use the LPPICTURE Render(*) function to display the image file into the DC, then use BitBlt(*) of CDC to display the image. The buttons are placed onto the form. This kind of works, although if I display another window over the form, or move the cursor into the title bar or the system status bar, all the buttons disappear. I would like to place the buttons dynamically, and tried to use SetWindowPos(*) for one of the buttons. But when I called SetWindowPos(*) for that button, everything (image and other buttons) disappeared. Is there a proper way to display buttons over an image so they don't disappear, and also to do so dynamically?
|
|
|
|
|
Maybe try on window focus to hide then reshow the buttons.
A small workaround!
|
|
|
|
|
I'm sorry, I don't understand. Do you mean call SetFocus() for the buttons?
|
|
|
|
|
There are four questions :
- where do you draw (what function of the view) ?
- where do you create the buttons ?
- how do you create the buttons ?
- what can you see at the places of the "hidden" buttons ?
virtual void BeHappy() = 0;
|
|
|
|
|
I call the functions to draw in the OnDraw(CDC* pDC) function of the CFormView
The buttons are put on the form with the resource editor, then I assigned names with class wizard.
The image is displayed correctly so it looks like the image is overwriting the buttons.
Interestingly, when the cursor is moved to the title bar, the OnDraw gets called, and the buttons disappear. I put in code to detect when the cursor is in the title bar and call Invalidate() in the form to cause OnDraw to be called again, then the buttons are displayed.
|
|
|
|
|
Please try to set WS_CLIPCHILDREN style to your form
(possible from the resource editor too)
virtual void BeHappy() = 0;
|
|
|
|
|