|
GetTextLength() is returning the length in characters.
How are you determining the number of bytes to write to the file?
For DBCS, length in characters is not the same as length in bytes.
DavidCrow wrote: Any clues?
You've considered using Unicode, I assume?
If not, you may have to write your own strlen , hunting from the start to a terminating zero, to get the number of bytes.
|
|
|
|
|
Graham Bradshaw wrote: How are you determining the number of bytes to write to the file?
I'm not. I just paste the text into Notepad and save it.
Graham Bradshaw wrote: You've considered using Unicode, I assume?
Yes, but I've read nothing thus far that says it would solve the problem. The application is 10+ years old so retooling it for Unicode would be no small undertaking.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
DavidCrow wrote: save it.
Save it how? Which encoding did you select?
|
|
|
|
|
Graham Bradshaw wrote: Save it how?
The Save option from the File menu.
Graham Bradshaw wrote: Which encoding did you select?
Once as ANSI (13 bytes) and another as UTF-8 (22 bytes).
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
So the text isn't 13 bytes long. It's more than that (UTF-8 encoding is not the same as DCBS, so the length of the ex-Notepad file is not relevant).
DavidCrow wrote: when I send this text and its length (13) to the AS/400 system for processing, it complains about a mismatched SoSi pair.
And that 13 is surely the problem. You need to send the length in bytes to the AS/400, together with all the text, not the length in characters. This assumes, of course, that the AS/400 understands DBCS encoding.
|
|
|
|
|
Graham Bradshaw wrote: You need to send the length in bytes to the AS/400, together with all the text, not the length in characters.
How do I go about doing this (since WM_GETTEXTLENGTH is giving me the latter)?
Graham Bradshaw wrote: This assumes, of course, that the AS/400 understands DBCS encoding.
It does. That's why it works (i.e., no data is lost) when I manually change the text length during debugging.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
DavidCrow wrote: How do I go about doing this (since WM_GETTEXTLENGTH is giving me the latter)?
You're working in C++?
If so, you must have a pointer to the start of the character buffer, so you can send it to the AS/400. Just hunt through byte by byte until you hit a zero, counting as you go.
|
|
|
|
|
The only way I know to calculate the number of bytes of DBCS string in a given encoding is:
1. Translate the string to Unicode (MultiByteToWideChar)
2. Translate the Unicode string to the previous encoding (WideCharToMultiByte) this function return the size of DBCS string in bytes.
This work (in all the case that I know of) .
Good luck.
|
|
|
|
|
Hi,
I want to create GroupBox on dialog box dynamically, can any one help me how to do that..?
Thanks
Venkatesh.
|
|
|
|
|
Group boxes are actually buttons with the BS_GROUPBOX[^] style set. I hope that helps.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
Well, I sure know it helps me a ton! Thank you!
|
|
|
|
|
Yourwelcome. Nice to see old posts can still be helpful.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> //TODO: Implement signature here<
|
|
|
|
|
hi if u got to how to create groupbox dynamicaly pls let me know
Thanks
|
|
|
|
|
I use visual studio 2005 MFC dialog based
I try to use these method to help but it doesn't give me a correct position.
void CMy3DGUIDlg::OnStnClickedPic1()
{
CWnd* prnt = GetDlgItem(IDC_PIC1);
CPoint p1;
GetCursorPos(&p1);
ClientToScreen(&p1);
prnt->ScreenToClient(&p1);
CDC *pdc = prnt->GetDC();
pdc->MoveTo(0,0);
pdc->LineTo(p1.x,p1.y);
}
Thank you for helping
|
|
|
|
|
z01e wrote: ...but it doesn't give me a correct position.
Position of what?
Have you tried GetMessagePos() ?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
|
There you have use mouse related events...
|
|
|
|
|
See the documentation of GetCursorPos[^], it tells you:
Retrieves the cursor's position, in screen coordinates.
z01e wrote: GetCursorPos(&p1);
ClientToScreen(&p1);
With this you are getting the cursor position in screen coordinates and then you are converting it to screen cordinates.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
so what function should i use to get coordinate in picture control?
p.s. sorry ,i'm very newbie for mfc. It would be kind if you could explain clearly.
Thank you
|
|
|
|
|
Well, you can either try this (using GetMessagePos()[^] as DavidCrow already suggested):
CPoint Pt(GetMessagePos());
or
POINT Pt;
GetCursorPos(&Pt);
picture_control.ScreenToClient(&Pt);
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
thank you very much Code-o-mat.
and how can i keep these lines after i draw because in just a few second
all lines are disappear.
|
|
|
|
|
I'm not sure what you mean, but if my guess is correct, you are drawing onto the picture control with the mouse. In this case, you will either have to remember what lines you have drawn, this aproach is more complicated, or simply, draw ONTO the bitmap in memory also, not just the window, this is probably easier done. Create a memory DC, select the bitmap into it and use MoveTo/LineTo to draw your lines. Don't forget to clean up after you are done drawing.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
i try to search MemDC but i don't understand. T_T
can i have example of MemDC and where do i put these function in if i want to show these lines on the image(old) until i load new image, these lines will gone?
thanks for your help
|
|
|
|
|
Well, if you load a new bitmap into your picture control then yes, the lines will be gone. And for the memdc, you can do something like this:
CDC MemDC;
MemDC.CreateCompatibleDC(dc_of_picture_control);
CBitmap *origBitmap = MemDC.SelectObject(pointer_to_bitmap_you_want_to_draw_to);
MemDC.MoveTo(0, 0);
MemDC.LineTo(line_to_x, line_to_y);
MemDC.SelectObject(origBitmap);
MemDC.DeleteDC();
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
void CMyGUIDlg::OnStnClickedPic1()
{
CWnd* prnt = GetDlgItem(IDC_PIC1);
CDC *pdc = prnt->GetDC();
CDC MemDC;
MemDC.CreateCompatibleDC(pdc);
CBitmap *origBitmap = (CBitmap*)MemDC.SelectObject(&m_pic1); //m_pic1.SetBitmap("LenaRGB.BMP");
MemDC.MoveTo(0, 0);
MemDC.LineTo(100,100 );
MemDC.SelectObject(origBitmap);
MemDC.DeleteDC();
}
T_T still can't do it. i try what you said but it is still no line after i minimize it.
hope you not bored me yet i'm sorry but thank you very much
|
|
|
|