|
Thanks for your reply.
<code>
CString aStr = "中文";//a Chinese CString
char cChinese[3];
cChinese[2] = '\0';
int i = 0;
while (i<aStr.GetLength())
{
if ((byte)aStr[i] >= 0xA1 && (byte)aStr[i] <=0xFE)
{
cChinese[0] = aStr[i];
cChinese[1] = aStr[i+1];
UINT aWord = cChinese // is it possible to assign the arrary to UINT
++i;
}
++i;
}
</code>
|
|
|
|
|
wow9999 wrote:
char cChinese[3];
UINT aWord = cChinese;
Here, you are trying to put the address of your chinese character into the UINT variable.
You could force the compiler to do that, but it probably makes no sense here.
What are you trying to achive here? Assign one chinese letter to the UINT?
Then you need to write something like UINT aWord = cChinese[i];
That means you need to say which letter you want to assign.
Who is 'General Failure'? And why is he reading my harddisk?!?
|
|
|
|
|
wow9999 wrote:
UINT aWord = cChinese // is it possible to assign the arrary to UINT
Yes (at least under VC++ 6.0).
You would need to write it as so:
UINT aWord = (UINT)cChinese;
This is what I said in my previous post. You need to cast it.
But the real question is why? When you assign the value of cChinese to an UINT you are not assigning the value of any char in cChinese - you are only copying the address of the zeroeth element.
If you are trying to look at or manipulate the character codes for the Chinese character set, then you need to assign cChinese[0] to aWord and not cChinese.
|
|
|
|
|
Hi:
Anyone know how to convert a string of data that can be converted into a Bitmap using Visual C++ embedded under Window CE 3.0??
Thanx
|
|
|
|
|
#include <iostream><br />
using namespace std;<br />
<br />
char matrix [3] [3];
<br />
char check();<br />
void init_matrix();<br />
void get_player_move();<br />
void get_computer_move();<br />
void disp_matrix();<br />
<br />
int main()<br />
{<br />
char done = ' ';<br />
<br />
init_matrix();<br />
<br />
do{<br />
disp_matrix();<br />
get_player_move();<br />
done = check();
if(done != ' ') break;
get_computer_move();<br />
done = check();
system("cls");<br />
} while(done == ' ');<br />
<br />
disp_matrix();
<br />
if(done=='X') <br />
cout << "You won!\n";<br />
if(done=='O')<br />
cout << "I won!\n";<br />
<br />
cout << "Programmed by:\n Tom Dziedzic \n";<br />
<br />
return 0;<br />
}<br />
<br />
void init_matrix()<br />
{<br />
int i, j;<br />
<br />
for(i=0; i<3; i++)<br />
for(j=0; j<3; j++) matrix[i][j] = ' ';<br />
}<br />
<br />
void get_player_move()<br />
{<br />
int x, y;<br />
<br />
cout << "Enter X,Y coordinates for your move: ";<br />
cin >> x;<br />
cin >> y;<br />
<br />
x--; y--;<br />
<br />
if(matrix[x][y]!= ' '){<br />
cout << "Invalid move, try again.\n";<br />
get_player_move();<br />
}<br />
else matrix[x][y] = 'X';<br />
}<br />
<br />
void get_computer_move()<br />
{<br />
if(matrix[1][1] == ' ')<br />
{<br />
matrix[1][1] = 'O';<br />
goto e;<br />
}<br />
if(matrix[0][0] == ' ' && matrix[1][1] == ' ' && matrix[2][2] == ' ')<br />
{<br />
matrix[2][2] = 'O';<br />
goto e;<br />
}<br />
e: ;<br />
}<br />
<br />
void disp_matrix()<br />
{<br />
int t;<br />
<br />
for(t=0; t<3; t++) {<br />
cout << matrix[t][0] << " | " << matrix[t][1] << " | " << matrix[t][2];<br />
if(t != 2) <br />
cout << "\n---|---|---\n";<br />
}<br />
cout << "\n";<br />
}<br />
<br />
char check()<br />
{<br />
int i;<br />
<br />
for(i=0; i<3; i++) <br />
if(matrix[i][0]==matrix[i][1] && matrix[i][0]==matrix[i][2]) <br />
return matrix[i][0];<br />
<br />
for(i=0; i<3; i++) <br />
if(matrix[0][i]==matrix[1][i] && matrix[0][i]==matrix[2][i]) <br />
return matrix[0][i];<br />
<br />
if(matrix[0][0]==matrix[1][1] && matrix[1][1]==matrix[2][2])<br />
return matrix[0][0];<br />
<br />
if(matrix[0][2]==matrix[1][1] && matrix[1][1]==matrix[2][0])<br />
return matrix[0][2];<br />
<br />
return ' ';<br />
}
this is what i have so far... though I'm trying to make the computer first search if the user will win in the next move and then block it if it can, and then if it doesn't then find a row it can fill. Please I need help, comments, suggestion, articles, please anything at all which would make the computer react like a human would...
P.S. TAKE YOUR TIME, don't rush
<marquee>Universal Project... Soon to be a .net
|
|
|
|
|
Is it September already?
Here is a pointer that ight work:
Any of the numbers shown on the outside of the grid are "winning" moves
1 | 2 | 4 = 7
------------------
8 | 16 | 32 = 56
------------------
64 | 128 | 256 = 448
/ =============== \
84 73 146 292 273
The numbers below show all of the possible conditions for a player that can win on the next turn:
R1: ( 3, 5, 6)
R2: ( 24, 40, 48)
R3: (192, 320, 384)
C1: ( 9, 65, 72)
C2: ( 18, 130, 144)
C3: ( 36, 260, 288)
D1: ( 17, 257, 272)
D2: ( 20, 68, 80)
|
|
|
|
|
I'm sry I'm not that advanced with understanding it, can you further explain your reasoning, I would appreciate it, THANKYOU
<marquee>Universal Project... Soon to be a .net
|
|
|
|
|
Anyone here was successfull at adding XP themes to it's DLLs? If so, how? I added the manifest and called InitCommonControls but it doesn't work.
Is there anything particular to add in the manifest since it's a dll or where do I need to call InitCommonControls (which function?)
It's for a Outlook add-in by the way...
thanks!
---------------
Tired of Spam? InboxShield 2.0.2 for Microsoft® Outlook® 2K/2K2/2K3
http://www.inboxshield.com
|
|
|
|
|
i don't really understand you question...
what e.g. does adding
LukeV wrote:
XP themes to it's DLLs
mean? what is "it's"?
Don't try it, just do it!
|
|
|
|
|
I have opened a JPG file just to read the header and determine if it is in fact a JPG, but I also want the width and height in pixel of the image. I this easy to acheive? Or does it involve decompressing the stream or something?
There doesn't appear to be 2 fields in the header which hold this information that really sux....
I just need a quick yes or no...please don't refer me to any image lib's or classes here on CP...I only need to know if getting the width and height of a JPG in pixel is almost as easy as retreiving the sig???
Thanks
I'm drinking triples, seeing double and acting single
|
|
|
|
|
There is no height or width in the file - as there is no header. JPEG is a compression specification that has grown into a file format. You can extract the width from the first scanline.
|
|
|
|
|
i was afraid of that
I'm drinking triples, seeing double and acting single
|
|
|
|
|
After moving to the .NET studio I'm experencing problems running my app. When I run it I get an error:
Runtime Check Failure #2 Stack around the variable 'sDataParse' was corrupt.
Can someone explain this error to me please. The variable pertains to a section of code that I copied from the MSDN concerning the API strtok.
I'm passing a LPSTR to this function that has that snippet of code in it. Do I need to delete this LPSTR before I exit my function?
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
No IDE is perfect. Visual C++ .NET 2003 has its flaws.
Kuphryn
|
|
|
|
|
okay...this doesn't really help.
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
The message is a diagnostic telling you that there is a buffer overrun or a problem with an out-of-range index into a buffer. If you're doing strcpy or sprintf it might be that the buffer 'sDataParse' is too small. Are you also passing a string length, assuming that you're passing the LPSTR as a destination of some kind?
Steve S
|
|
|
|
|
that's not a problem of .NET studio, it's one of your software!
this error is caused by a call(in debug mode) at the end of a function, which checks if the stack layout has been modified!
Don't try it, just do it!
|
|
|
|
|
Hi again:
Another problem, I am able to maximize the main window and the tabctrl that is on it, but what it is inside the tabcontrol doesn't change the size. Any idea?
Thanks
|
|
|
|
|
Hi, I've developed a NT Service in C++. This service receives requests, and do some processing depending on these. One kind of request is displaying a DialogBox, but this never shows up. In the DialogBox procedure, the WM_INITDIALOG never arrives. If I try to launch a graphic app like calc.exe, the process runs, but never display it's interface. It looks like any GDI operation it's not available in my service. Any idea?
Tnx
|
|
|
|
|
Posting a dialog from a service isn't really a great thing to do. And there's issues around doing such things. Issues about how the service is installed, and which user this service is bound to:
First question: when you install this service, are you installing it using CreateService() and are you specifying the SERVICE_INTERACTIVE_PROCESS flag in dwServiceType parameter?
<br />
SC_HANDLE CreateService(<br />
SC_HANDLE hSCManager,<br />
LPCTSTR lpServiceName,<br />
LPCTSTR lpDisplayName,<br />
DWORD dwDesiredAccess,<br />
DWORD dwServiceType,<br />
DWORD dwStartType,<br />
DWORD dwErrorControl,<br />
LPCTSTR lpBinaryPathName,<br />
LPCTSTR lpLoadOrderGroup,<br />
LPDWORD lpdwTagId,<br />
LPCTSTR lpDependencies,<br />
LPCTSTR lpServiceStartName,<br />
LPCTSTR lpPassword<br />
);<br />
The moral is -- you should first scrutinize how your service is installed on your machine.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.santacruznetworks.com">Santa Cruz Networks</A>
|
|
|
|
|
|
Hi
How could i set up a scroll bar inside a tab control. That's it: I created a tab control, one of the window that I want to show inside is going to be huge, so I want to be able to scroll on it. I tried to set up the dialog shown with the option of vertical scroll but doesn't work.
What am I mising?
Thanks.
|
|
|
|
|
void CTabOne::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
if (pScrollBar-> GetDlgCtrlID()==IDC_SCROLLBAR1)
{
int nCurrentPos = pScrollBar-> GetScrollPos();
switch(nSBCode)
{
case SB_PAGEUP:
pScrollBar->SetScrollPos(nCurrentPos-5);
break;
case SB_PAGEDOWN:
pScrollBar->SetScrollPos(nCurrentPos+5);
break;
}
}
CDialog::OnVScroll(nSBCode, nPos, pScrollBar);
}
One problem is that I have no idea what the IDC_SCROLLBAR1 is, because I am not able to set up the IDC of the scroll bar
Other is that when I get rid of the if condition, I get an error and the program ends.
Any comment?
Thanks, Ruben
|
|
|
|
|
My BMP image is mainly green in colour. I want to change to red but I can't get even Paint Shop Pro to do this simple operation!
If I wrote code to do it, I would simply swap values of each pixel's green and red values.
For example (50, 150, 50) would become (150, 50, 50). This would not affect white or black pixels.
Can anyone help?
|
|
|
|
|
To do it in windows code is easy.
1) If you only need to swap the values, and speed is not a problem, you could just select it into a Device Context and do something like this
ClrRef = GetPixel(x,y);
ClrRef = SwapRG(ClrRef); // user defined func.
SetPixel(x,y);
Saving it back to disk is where life gets difficult.
1) Read the articles at code project, and other sights to find out how.
*2) Read "Programming Windows" by Charles Petzold.
INTP
|
|
|
|