|
CPallini wrote: Tetris source file at www.cpallini.freproductz.com/gamez/tetris/src
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|
|
What is a collecton of statements in a human-readable programming language, Alex?
"Love people and use things, not love things and use people." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
The Daily Double
Good answer -- er question (or something like that)
|
|
|
|
|
Hi,
I am wondering how I can get the text from an scintilla text control ? This is my code, but the debugger says that data has a bad pointer and I have no text in it.
TCHAR *data;
UINT nLength;
nLength = SendMessage(hWndEditor,SCI_GETLENGTH,0,0);
memset(&data,0,sizeof(TCHAR)*nLength+1);
data = (TCHAR*)SendMessage(hWndEditor, SCI_GETTEXT,nLength+1,0);
MessageBox(NULL,data,L"MyApp",0);
free(data);
Thanks for help.
bye,
gabbana
|
|
|
|
|
gabbana wrote: data = (TCHAR*)SendMessage(hWndEditor, SCI_GETTEXT,nLength+1,0);
shouldn't that be
nLength = SendMessage(hWndEditor, SCI_GETTEXT,nLength+1, (LPARAM)data);
?
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]
modified on Sunday, October 26, 2008 2:41 PM
|
|
|
|
|
Hmm,
I get an error:
cannot convert from TCHAR* to UINT
And the last parameter i needed to cast (LPARAM)data.
|
|
|
|
|
In fact I forgot a cast. I fixed (there also was a wrong cast,by cut 'n' paste, actually) my previous reply, please see it again.
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]
|
|
|
|
|
Okay, but without luck.
Iam not sure what the error exactly is, but if I have a breakpoint at the last SendMessage and look in the Debugger &data have a value of 0x00... and Bad Ptr
And the MessageBox is empty.
The code looks like this:
UINT length = SendMessage(hWndEditor, SCI_GETLENGTH, 0, 0);
TCHAR *data;
memset(&data, 0, sizeof(TCHAR)*length+1);
length = SendMessage(hWndEditor, SCI_GETTEXT,length+1,(LPARAM)data);
MessageBox(NULL,data,L"Test",0);
free(data);
At the end of the function I also get this error:
Stack around the variable 'data' was corrupted
modified on Sunday, October 26, 2008 11:16 PM
|
|
|
|
|
gabbana wrote: TCHAR *data;
memset(&data, 0, sizeof(TCHAR)*length+1);
I think before memset you should allocate memory for data.
You can insert following statement before memset.
data = new TCHAR[length+1];
I hope it helps.
Regards,
Sandip.
|
|
|
|
|
I get the same error.
What I found now is, that if i only allocate memory with your code and removing the memset and free functions I get no error, but the MessageBox and the gives me some crazy char like chinese. (I think I should mention that I use UNICODE)
|
|
|
|
|
one thing i missed do not use free when you are allocating memory with new.
use delete instead of free.
gabbana wrote: (I think I should mention that I use UNICODE)
Have you set the corresponding properties for using unicode.
In the documentation i see following messages.
SCI_SETKEYSUNICODE(bool keysUnicode)
SCI_GETKEYSUNICODE
You can try setting keysUnicode to TRUE in message SCI_SETKEYSUNICODE
I hope it helps.
Regards,
Sandip.
modified on Monday, October 27, 2008 4:48 AM
|
|
|
|
|
Okay, now I am using delete. The stack corrupted message already exists. The error must be the memset, because if i delete that line I am not getting an error. The problem with the chinse chars already exists!
hWndEditor is the handle to sintilla text control. I declared it in my header file HWND hWndEditor and created the control in the WM_CREATE message:
hWndEditor = CreateWindowEx(0,
_T("Scintilla"),
_T(""),
WS_CHILD | WS_VISIBLE,
0,
0,
500,
500,
hWnd,
(HMENU)1,
(HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE),
NULL);
EDIT:
Yes i send the following message in WM_CREATE after the control is created:
SendMessage(hWndEditor, SCI_SETKEYSUNICODE, true, 0);
|
|
|
|
|
Does nobody has an idea how to fix the problem ?
By the way:
Is Scintilla a good choice, or would it be better to use the rich text edit control and write own functions to extent it, because i am learning c++, and probably it would be better for learning.
|
|
|
|
|
I believed the reason for the "chinese" chars is because you have NOT established memory for the varable yet. Always, always zero out a varable before it is used: Example: CString str;(you've declared it and it resides in memory, but what is presently at that memory location?) just do this str = ""; or in Unicode: str = _T(""); Now that location is clean for str. I don't know anything about "Scintilla" I've always used the rich edit control methods. Codeproject has multiple examples that show how.
A C++ programming language novice, but striving to learn
|
|
|
|
|
Hi,
I need to use the following header file, in my
project: stdint.h . But, I've found several
of their versions online, and I am not sure which
one of them to use. I'd appreciate if someone
could provide me with a link to the real stdint.h
file.
Thanks!
|
|
|
|
|
Iwant to know how to distinguish between physical drive and logical drive
API like Getlogicaldrives and getdrivetype doesn't help me
how to know is this physical or virtual CDROM ?
nothing else
|
|
|
|
|
Hi,
I have a big problem. I am trying to use the simple method MoveFile but getting Error code 5: Access denied. I have Windows Vista and UAC enabled. If I right click on the app and select "Run as administrator" -> everything works fine.
My problem is, many users have normal accounts and don't run apps as an administrator. So my question is how can i implement the feature to move the file as a normal user?
Thanks.
bye,
gabbana
|
|
|
|
|
Where is the file being moved from/to? If it's the Program Files directory there's not much you can do about that.
Regards,
--Perspx
"I've got my kids brainwashed: You don't use Google, and you don't use an iPod." - Steve Ballmer
"Some people have told me they don't think a fat penguin really embodies the grace of Linux, which just tells me they have never seen an angry penguin charging at them in excess of 100mph." - Linus Torvalds
|
|
|
|
|
The files moving from C:\myfile.txt to C:\myapp\txt
So its my own directory...
|
|
|
|
|
If the file is set to "Read Only" this problem will occur. Vista is looking for permission to move that file, so something is telling Vista that it needs permission to move that file. Check the files property.
A C++ programming language novice, but striving to learn
|
|
|
|
|
i need help in converting a
"string" to "LPTSTR"
or "char *"
please help
|
|
|
|
|
|
Before you try to do some nasty casting or conversion in your code, I suggest that you take a look at this article[^]. Things will get much clearer afterwards
|
|
|
|
|
"before posting, answer this question.
are you asking about converting strings?
see this article..."
|
|
|
|
|
I think we should add that in the posting guidelines, yes
I don't know how many times I already linked to that article but it is a lot.
|
|
|
|