|
Hello,
I used GetCaretPos() to get the caret/cursor position in the CRichEditCtrl box but I am not getting the proper position.
When the cursor is placed before the first character in the text and I
write the following code
CPoint Charpoint;
GetCaretPos(Charpoint);
The answer is
Charpoint.x = 8 Charpoint.y=0;
whereas Charpoint.x = 1 should be the answer
Which other function should I use.
Regards,
Pritha
|
|
|
|
|
Well, the Caret and the Cursor are two different things. The cursor is moved with the mouse, and the Caret is changed by (eg) the edit control. It will typically be a flashing vertical line. Where is *it*?
You may have just clicked in the control and given it the focus. You'd need to click again to get the caret where the mouse is.
Lastly, if it's before the 1st char, I'd expect x = 0 myself. But the reply is in pixels, not chars, so maybe there's an 8 pixel wide margin?
Iain.
I have now moved to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need cotract work done, give me a job! http://cv.imcsoft.co.uk/[ ^]
|
|
|
|
|
prithaa wrote: whereas Charpoint.x = 1 should be the answer
Nope. You should read the documentation[^] before using a function you don't know. As specified in the doc, the function returns the client coordinates of the caret pos (so, a "screen" position, not a character index).
You have to use the CharFromPos[^] function to convert the position into a character index.
|
|
|
|
|
|
Hello,
I am writing my question here since it was a continuation of the earlier question.
I found that there is no function CharFromPos() in CRichEditCtrl but I used the notification WM_CHARFROMPOS and got the character position.
I have a n CRichEditCtrl boxes on screen but not all boxes show the character position as 1 when the box receives focus.But actually the character position is 1. The following is the code in the OnSetFocus() of the class derived from CRichEditCtrl.
void CRICH::OnSetFocus(CWnd* pOldWnd)
{
CPoint CharPoint ;
CharPoint = GetCaretPos();
POINTL A; A.x = CharPoint.x; A.y = CharPoint.y;
int result = SendMessage(EM_CHARFROMPOS,(WPARAM)0,(LPARAM)
&A);
int charpos = LOWORD(result);
CRichEditCtrl::OnSetFocus(pOldWnd);
}
What must be the problem ?
Thanks for your guidance
Pritha
|
|
|
|
|
Hi friends, I am trying linking a static library build with gcc (libjulius and libsent) with my code in c++ using vc++, I have made some tests.
I create an .a library with gcc, called fatorial.a and their include (fatorial.h) in a folder include so I create a main.c which call a function fatorial(int) which exists in file fatorial.h and their implementation in fatorial.a, so I can compile with cl like this:
cl /Iinclude main.c \link include\fatorial.a
this works fine.
Now with libjulius and libsent I have one folder called julius4 whose structure is showed below
the statics libraries is
julius4\libjulius\libjulius.a
julius4\libsent\ilbsent.a
theirs include are in
julius4\libjulius\include
julius4\libsent\include
there is an file julius4\libjulius\libjulius-config that when run with argument --libs return the requeried libs
and another julius4\libsent\libsent-config with the same objective, this libs are the libs which exists in libjulius.a and libsent.a respectively, when I run that scripts this returns -ljulius -lpthread -lsent -lwinmm -liconf -lm (-l is the option to search for the library in gcc).
so to compile my code main.cpp with gcc I call it like this:
gcc -Ijulius4\libjulius\include -Ijulius4\libsent\include main.c -o main.exe -Ljulius4\libjulius -Ljulius4\libsent -ljulius -lpthread -lsent -lwinmm -liconf -lm
and this works trying to map to cl I run like this
cl /Ijulius4\libjulius\include /Ijulius4\libsent\include main.c -o main.exe \link julius4\libjulius\libjulius.a julius4\libsent\libsent.a /DEFALTLIB:julius /DEFALTLIB:pthread /DEFALTLIB:sent /DEFALTLIB:winmm /DEFALTLIB:iconf /DEFALTLIB:m
but this find only the lib winmm and can not find iconf.lib m.lib...
Can anyone help me? Thanks.
|
|
|
|
|
- Use "/link" rather than "\link"
- Don't bother using /defaultlib (even if you had spelt it correctly). Just list them on the command-line after the /link with their full names. The standard unix linker does a bit of magic when you use
-llibrary-name - it adds 'lib' to the front of the library-name and '.a' as a suffix, so -ljulius is the same as adding libjulius.a to the command-line.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
1 - I am using link right just put here wrong.
2 - Okay, I try do not use /DEFAULTLIB, using just the address julius4\libsent\libm.a for an example but the message is the same it can not find this file and right this does not exists, I think this is implicit in the file libsent.a and libjulius.a, but I do not know what command I do to make the compiler look for them.
When I try without the /DEFALTLIB cl return me a lot of unresolved links (54), but if I include /DEFAULTLIB:winmm this find winmm and solve some links the error is now 33 unresolved links. Repeat does not exists any file named winmm.a or winmm.lib or something like this, the problem is this found only winmm. (I think is that if I wrong sorry).
Very thanks for the help man, if you have other thinking I am listening.
|
|
|
|
|
You'll also need to tell it what path to look on. The LIB environment variable should already specify the directory containing all the standard Windows libraries. If not, set that directory and the one for your libraries with the /libpath[^] linker option.
winmm.lib should be in Visual C++'s library directory - either that or the Platform SDK's library directory.
I just built a C++ app with this command-line:
cl -EHsc a.cpp /link winmm.lib
The LIB environment variable contained the Platform SDK directory:
> set LIB
LIB=c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\ATLMFC\LIB;c:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\LIB;C:\Program Files\Microsoft SDKs\Windows\v6.0A\lib;
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Yes man, each file .a contains only one library, so the others libraries I have cited is others .a files that windows do not contains for default. So I install cygwin and copy this libraries the problem is that this is not enough there is any links that until is unresolved, but I am now with more knowledge and work on it.
Thanks.
|
|
|
|
|
Hi
I want to change the "if and else" statement of the following code in to a different fashion,(not with if and else ladder)
what i want to achieve with the code is: Any one of the pointers (p1,p2,p3) will be non NULL...at any given time. (For the time being I am hard-coding with the address of value i, but in actual I may be passing the i value to the function) Others will be NULL for sure...i need to check which is not NULL...that's it
Note: I would be using dynamic_cast, to assign the i value later..... [dynamic_cast returns 0, if cast was not happened ]
int i=10;
int *p1=NULL;
int *p2=&i;
int *p3=NULL;
if(p1!=NULL)
{
printf("\n\np1");
}
else if(p2!=NULL)
{
printf("\n\np2");
}
else if(p3!=NULL)
{
printf("\n\np3");
}
else
{
printf("\n\nnone");
}
thanks in advance
-----------------------------
I am a beginner
modified on Friday, September 4, 2009 8:22 AM
|
|
|
|
|
hrishiS wrote: I want to change the following code, if and else to anything else
The else without the associated condition handles the "anything else" case.
hrishiS wrote: the code logic is : Any one of the pointers will be non NULL...at any time.others will be NULL for sure...i need to check which is not NULL...that's it
I don't follow. Please elaborate.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Hi
I want to change the "if and else" statement of the following code in to a different fashion,(not with if and else ladder)
what i want to achieve with the code is: Any one of the pointers (p1,p2,p3) will be non NULL...at any given time. (For the time being I am hard-coding with the address of value i, but in actual I may be passing the i value to the function) Others will be NULL for sure...i need to check which is not NULL...that's it
Note: I would be using dynamic_cast, to assign the i value later..... [dynamic_cast returns 0, if cast was not happened ]
int i=10;
int *p1=NULL;
int *p2=&i;
int *p3=NULL;
if(p1!=NULL)
{
printf("\n\np1");
}
else if(p2!=NULL)
{
printf("\n\np2");
}
else if(p3!=NULL)
{
printf("\n\np3");
}
else
{
printf("\n\nnone");
}
thanks
-----------------------------
I am a beginner
|
|
|
|
|
hrishiS wrote: I want to change the "if and else" statement of the following code in to a different fashion,(not with if and else ladder)
And what other way of checking variables against NULL did you have in mind?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
That looks a lot like the original question. David is one of our best answerers. If you want his help, and he asks you a question.... You should answer it, or give up on people helping you.
Iain.
I have now moved to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need cotract work done, give me a job! http://cv.imcsoft.co.uk/[ ^]
|
|
|
|
|
Iain Clarke, Warrior Programmer wrote: and he asks you a question.... You should answer it
Or more often than not, his questions are the answers.
(I like his style)
|
|
|
|
|
printf("\n\n%s", p1 ? "p1" : (p2 ? "p2" : (p3 ? "p3" : "none")));
|
|
|
|
|
Hi friends,
We develop an application under MSVC++ 2005 and now my task is to remove the memory leaks. In fact I found some problems especially “new” and “delete” instructions that aren’t paired and also some cases when they was inappropriate used. The main problem is the memory used by the app. When I run it multiply time the total used memory reported by Windows Task Manager increases (between two playing the difference of memories isn’t the same in generally). I suspect that the problem isn’t memory leaks. Can u help me with any advice?
Also as memory leaks I have some reported by MSVC library, how can I identify the exactly cause in my source for these, e.g:
f:\rtm\vctools\vc7libs\ship\atlmfc\src\mfc\map_pp.cpp(69): 68 bytes, allocating 'Normal' block (#155028)
f:\rtm\vctools\vc7libs\ship\atlmfc\src\mfc\plex.cpp(29): 124 bytes, allocating 'Normal' block (#155030)
f:\rtm\vctools\vc7libs\ship\atlmfc\src\mfc\map_pp.cpp(69): 68 bytes, allocating 'Normal' block (#274094)
Thanks in advance for your support
costica
|
|
|
|
|
In this situation MemoryValidator,BoundsChecker or alike developer tools may help. Try trial for free.
|
|
|
|
|
Thanks, I tried a lot of memory leaks detector software (included those indicated by you) but they did't give me useful information, this is the cause that make me to think that the memory increse when I "Play" multiple time has another cause.
|
|
|
|
|
Agavriloaie Constantin wrote: When I run it multiply time the total used memory reported by Windows Task Manager...
The numbers from TM are not telling you how much memory your program is consuming. They are the amount of address space that is in use, which will be less than the amount of address space your program is actually using.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Thanks David, maybe u are right, can you give me more info about this, it is the fist time when I heard about it (TM ). How can i find the exactly amount of memory used by app?
have a nice wked
|
|
|
|
|
Maybe the Performance Monitor has something you can use (e.g., Process(yourprocess)\Private Bytes).
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
I want to load a codejock skin,but not msstyles,
Does any body have and would like to share it?
|
|
|
|
|
You'll have to buy something that's sold for money. Nobody here is going to share it with you.
However, you could take a look at The Ultimate Toolbox Application Skins[^], which is free for use.
It is a crappy thing, but it's life -^ Carlo Pallini
|
|
|
|