|
Actully I am using wcslen(Text) instead of sizeof(Msg) Now. But still its giving me empty string in both EM_GETTEXTEX and EM_GETSELTEXT.
TCHAR *Text = new TCHAR[100];<br />
TCHAR SelText[100] = {};<br />
<br />
GetText.cb = wcslen(Text);<br />
GetText.flags =GT_SELECTION;<br />
GetText.codepage =CP_ACP ;<br />
GetText.lpDefaultChar = NULL;<br />
GetText.lpUsedDefChar = FALSE;<br />
<br />
lr =SendMessage(hChild,EM_GETTEXTEX,(WPARAM)&GetText,(LPARAM)Text);<br />
<br />
SendMessage(hChild,EM_GETSELTEXT,(WPARAM)0,(LPARAM)SelText);<br />
According to u I have made the changes. But Getting Access violation Error as below
access Violation in module Riched20.dll write at process 007C8268
I m not getting what is happening.
|
|
|
|
|
Following is the code i m using, and it's working.
CHAR Text[100];
GETTEXTEX GetText;
GetText.cb = sizeof(100);
GetText.flags =GT_DEFAULT;
GetText.codepage =CP_ACP ;
GetText.lpDefaultChar = NULL;
GetText.lpUsedDefChar = NULL;
::SendMessage(GetDlgItem (IDC_RICHEDIT21)->m_hWnd,EM_GETTEXTEX,(WPARAM)&GetText,(LPARAM)Text);
|
|
|
|
|
I am using win32 Dialog based application.
And the RichEditBox is in the other application
I have retrived the Handle of it through FindWindow() Function.
and When I use your code it gives me the Access violation Error.
I am not getting any Error when I set the text in the Rich Edit Control using WM_SETTEXT .
Do you have any idea why this is happening
|
|
|
|
|
if you are using WM_GETTEXT message from different process, in xp you will get Access Denied message (Atleast in an edit box with password option on).
For more information search CodeProject for "SUPER PASSWORD SPY" and read the details.
|
|
|
|
|
I know about that. But It is simple Rich Edit Box. And its Property is not setted to Password Type.
I.e. What ever I write down in that Rich Edit Box. I am able to see that. And I can retrive the Text using WM_GETEXT. but I want only the Text selected By user. Is there any other way to do it. Rather than EM_GETSELTEXT. Becoz it is unable to retrive the Text.
|
|
|
|
|
GauranG033 wrote: GetText.cb = wcslen(Text);
Text has no length, so 0 is being assigned to GetText.cb .
GauranG033 wrote: GetText.codepage =CP_ACP ;
Have you also tried 1200 here?
GauranG033 wrote: SendMessage(hEdit,EM_GETTEXTEX,(WPARAM)&GetText,(LPARAM)Text);
What value is returned?
GauranG033 wrote: SendMessage(hEdit,EM_GETSELTEXT,(WPARAM)0,(LPARAM)SelText);
This will obviously return 0 if no text is selected.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
You are right it return 0.
And I am using following .
TCHAR *Text = new TCHAR [100]
GetText.cb = wcslen(Text);
Bye the Way. When I use the EM_GETSELTEXT then also it return with 0 and Text is empty.
I dont think if I am using EM_GETSELTEXT i need to Initialize the GETTEXTEX structure. should I ??
I m using it like this.
<br />
lr = ::SendMessage(hChild,EM_GETSELTEXT,(WPARAM)0,(LPARAM)SelText);<br />
lr = 0 and Text = "" after it returns.
hChild is the Handle to Rich Edit Box which is in Different window.
I am retriving it through FindWindow()
|
|
|
|
|
GauranG033 wrote: TCHAR *Text = new TCHAR [100]
GetText.cb = wcslen(Text);
Text has no length, so 0 is being assigned to GetText.cb . I've heard that before, but can't recall where!
GauranG033 wrote: When I use the EM_GETSELTEXT then also it return with 0 and Text is empty.
As it should, when no text is selected in the control.
GauranG033 wrote: I dont think if I am using EM_GETSELTEXT i need to Initialize the GETTEXTEX structure. should I ??
Correct.
GauranG033 wrote: hChild is the Handle to Rich Edit Box which is in Different window.
I am retriving it through FindWindow()
So have you verified that the window handle is correct?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Handle is correct.
Because When I am using this handle to set/get the text in/from Rich Edit Box through WM_SETTEXT and WM_GETTEXT it's working.
But I want Only the text selected By user. So I am using EM_GETSELTEXT, but as i told you its not working.
|
|
|
|
|
GauranG033 wrote: But I want Only the text selected By user. So I am using EM_GETSELTEXT, but as i told you its not working.
This is just a guess, but have you considered selecting some text in the edit control before calling SendMessage() ?
<notice>
Please fix your screen name. I'm really tired of having to modify my posts as a result of your broken tag.
</notice>
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Yes, I am selecting the text before making a call.
And By the way I check the sup tag in my name and it is closed properly.
|
|
|
|
|
GauranG033Yes, I am selecting the text before making a call.
Then something else is going on, like the value of the cb member.
<blockquote class="FQ"><div class="FQA">GauranG033</sup wrote:</div>And By the way I check the sup tag in my name and it is closed properly.</blockquote>
Notice that it is not (two examples above). I'm not sure what you are looking at, but a quick look at the HTML source will show you otherwise. You can also respond to your own message, select a few words and click the Quote Selected Text button.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Please fix your name. You have a </sup> tag that is not closed properly.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
sir,
In My sample project i used IActiveDesktop::SetWallpaper method,But it is giving an RunTime error like The Instruction at "0x0041432a" referenced memory at "0x00000000". The memory could not be "read"
here the code is...................
void CSlidercontrolDlg::OnButtonSetdesktop()
{
// TODO: Add your control notification handler code here
USES_CONVERSION;
lp=A2CW(stWallpaper);
pIActiveDesktop->SetWallpaper(lp,0);
}
In this regard please rectify the runtime error what i am getting or send me an complete example which is using IActiveDesktop::SetWallpaper() and some other methods in IActiveDesktop.
Please send a solution as soon as possible
|
|
|
|
|
|
Hi there,
I've got a weird problem with Subclassing in MFC:
What I want is the following:
I want to create a custom control (CRotarySlider) based on the CSliderCtrl-Class of MFC. I want to disable the Paint-Function of the CSliderCtrl and draw myself.
Now I did this by overriding the OnPaint() and NOT calling the CSliderCtrl::OnPaint().
Also I want to create a MemDC and draw to this DC and then simply BitBlt the MemDC to the DC of the OnPaint() Function.
In a Test-Application where I create one of my SliderCtrl it all works out fine.
I put a CSliderCtrl onto the Dialog, then add a Member-Variable to the Dialog.h:
CRotarySlider m_mySlider;
Also, I add the control to the DoDataExchange():
DDX_Control(pDX, IDC_SLIDER1, m_mySlider);
As I said, everything works fine.
BUT: In the real project I need 10 of these Sliders. So I define them as before, but now in an array of Controls:
CRotarySlider m_mySliders[10]
and:
<br />
DDX_Control(pDX, IDC_SLIDER1, m_mySliders[ 0]);<br />
DDX_Control(pDX, IDC_SLIDER2, m_mySliders[ 1]);<br /> and so on.
The Dialog is created when I start the application, and shown at a specific point. But then I can't see anything of my controls.
They're not drawn.
And it seems that the creation of the MemDC fails. But I get NO message like WM_CREATE, or WM_SHOW. Nothing.
The only thing I receive is WM_CHILDACTIVATE. But at that time my DC seems to be incorrect. So the compatible MemDC is also incorrect.
I hope anyone of you has an idea about that. Sorry if this post is too long, but I don't know where the error may hide so I thought I give you as much information as possible.
|
|
|
|
|
You won't get WM_CREATE, as the initial sliders were created before WM_INITDIALOG was called. Off the top of my head, you can override a virtual CWnd::PreSubClass , as this is called when you're subclassing, or when you're creating a control.
For your problem, I'd comment out the memory DC bits until you are happy that its working without that.
Then, create the memory DC in your OnPaint handler. Check the ClientRect against the size of the MemDC, and recreate it if you have to. Then you don't need to worry about creation messages.
(Don;t forget to tidy up after it though!)
Iain.
|
|
|
|
|
Hi Iain,
thanks for your reply. Got a new Question:
When I override the CWnd::PreSubClass for my sliders. Do I have a correct DC at that point? Or is ist created afterwards? Or did you mean I should override PreSubClass and ALSO create the memDC in the OnPaint Handler? What for do I need the PreSubClass-Method then?
Thanks
|
|
|
|
|
I would ignore the PreSubClass completely (for this reason at least - for all I know you have other work to do).
And in your OnPaint handler, I would use Keith Rule's CMemDC class - creating the bitmaps will be pretty speedy, and it keeps your code clean. It will even blt the image to the screen with it goes out of scope.
Flicker Free Drawing In MFC[^]
I cannot recommend this article highly enough.
I used to cache my own memory DCs, but it wasnt worth the hassle, and the speed hit of recreating them is essentially 0.
Iain.
|
|
|
|
|
hi i am having ascii file for a model. how to draw the model by reading the ascii file using opengl. i am new bie to opengl. pls guide me
|
|
|
|
|
Have you looked to the articles section here in CodeProject?
There are a lot of samples at every level (also for newbie)
saisp wrote: i am having ascii file for a model
If it is a known format you can probally hope to find some ready code to import it...elseway you will need to write your custom code.
Russell
|
|
|
|
|
Hi,
I want to develop a Multithread SDI application where a ball(drawing an ellipse) is created for every thread.
The user is given the option of selecting N no of balls ( say N < 5).
The trajectory/movement of the ball is random of each other. These bounce-off once they hit any one of the sides of the client rect.
Assume that I have the points through which each ball has to traverse (which is different for each ball), how do i start of with this application?
|
|
|
|
|
I never made an application like this, but do you think it's necessairy to create
for each ball a thread?
If i should make it, i create a class Ball and instanciate for each ball a new object.
Because the drawing is made (in every case) at the main thread (The GUI-Thread)
Normally the balls are flying with the same speed, so with a timer you redraw each time
the new position of the balls. The new position of the ball is calculated into the object.
I hope i don't say bullshit
|
|
|
|
|
baerten wrote: I never made an application like this, but do you think it's necessairy to create
for each ball a thread?
What I had in mind was for each thread, within that thread, I Create a ball object and in a while loop, get the necessary paramerers (trajectory) of the ball by making call functions. Periodically I keep updating the UI with the info.
|
|
|
|
|
You really don't need to be using a thread for each ball. As another poster said, create an instance of a class for each and update the class on each loop of your code.
You also might want to do some searching for an algorithm called "collision detection" which is almost exactly what you are trying to accomplish.
Waldermort
|
|
|
|