I develop a program, in it I realize the recording of a snapshot from a webcam in the database.
While at the development level I try to save at least a file.
Used the code:SendMessage(hWndC, WM_CAP_SAVEDIB, 0, longint(pchar('name.bmp')));
But for some reason only saves the first letter for the file name.
How to fix this bug?
- onePerhaps - the difference in Ansi / Unicode. If the receiving window is Ansi, and Delphi is Unicode, then so be it. Variant two - either create a receiving window via W-functions, if possible, or explicitly bring the string to AnsiChar and then to PAnsiChar. - kami
|
2 answers
Apparently, the receiving window considers the ANSI information received as a string, in which each character has 1 byte. If Delphi is unicode, then PChar is PWideChar , where each character is two bytes. For English characters, the high byte will be 0. Taking into account the fact that the PChar line ending is based on the character #0 - the ANSI window is completely entitled to calculate the high byte of the first character ( #0 ) for the line ending.
There are two possible solutions:
- Create receive window via W functions (Unicode)
- Explicitly convert the transmitted string to Ansi, i.e.
PAnsiChar(AnsiString('name.bmp'))
- Thank you very much. Used a simpler, second way. - I_CaR
|
pchar is a character type, try using a string type. I can also suggest to look at a solution to the problem in this topic.
pchar - это символьный тип, попробуйте использовать строковый тип.Explain this statement (incorrect, by the way) and add, what kind of "string type" do you mean in WinAPI terms? - kami- On msdn it is said that it is a pointer to a character, so I proceeded from this. If this is not the case, then I apologize for the misinformation. - Aim X
- 2
PCharis a pointer to the first character of a string. Directly by the pointer contains the first character. The end of the line is considered terminal 0 (the character with the code 0). But how many bytes will occupy this terminal zero depends on whether it is PAnsiChar or PWideChar. - kami - Everything is clear, I will know. - Aim X
|