|
Thanks a lot! I've fixed the error like You told me and now everything works properly and I'm very happy about that
|
|
|
|
|
hi guys
i need help on this real bad....
i posted this messege earlier but didnt solve the problem .. will someone plese respond to this .. please...........
I have a MFC application dialog based.. has 2 dialog forms say dialog1 and dialog 2.. in dialog1 i have a picture holder (IDC_HOLDER). what i need to do is get the "Rect" value of that holder from dialog2 .. i can do that from dialog1 with
CRect rc;
GetDlgItem(IDC_HOLDER)->GetWindowRect(rc);
but how to access that from dialog2....
i tried
CDialog1* dlg;<br />
dlg->GetDlgItem(IDC_HOLDER)->GetWindowRect(rc);
doesnot work...
my whole project has come to HALT by this ... please help .. someone !!!!!
thanks
zm
where are all the GURUS???
|
|
|
|
|
|
Does dialog1 open dialog2? If it does, try the following:
1. Give dialog2 a member variable - HWND m_hWnd1;
2. Before dialog1 opens dialog2 use - dialog2.m_hWnd1 = m_hWnd;
Then use:
RECT r;
::GetWindowRect(::GetDlgItem(m_hWnd1, IDC_HOLDER), &r);
|
|
|
|
|
Admission of guilt
This is a shameless ploy to get my fellow CPians help this sleep deprived developer meet yet another (self-imposed) insanely aggressive deadline.
Anyone care to provide the implementation of (or a pointer to) this word wrap method?
void wordWrap
(CString strText,
int nWrap,
CPtrArray& lines);
Example:
CString strText = "The quick brown fox jumps over the lazy dog";
CPtrArray lines;
wordWrap (strText, 17, lines);
ASSERT (lines.GetSize() == 3);
ASSERT (lines[0] == "The quick brown");
ASSERT (lines[1] == "fox jumps over");
ASSERT (lines[2] == "the lazy dog");
Many thanks!
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Best I can do on short notice is this article[^].
Two problems with it.
1) It's in VB, so some translation is needed
2) It pads lines with spaces, so some truncation is needed
I would guess that doing those two is less effort than developing it from scratch!
|
|
|
|
|
Thanks, Graham! I'd come across that one as well as a couple of implementations in Java. PJ Arends rose to the occasion and (not surprisingly) crafted a great solution.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
nWrap is the maximun number of characters in the line?
Does lines have to be CPtrArray, or can it be redeclared as a CStringArray instead?
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
void wordWrap (CString strText, int nWrap, CStringArray &lines)
{
int count = 0;
TCHAR *ptr = strText.GetBuffer(strText.GetLength() + 1);
TCHAR *EndofLine = ptr;
TCHAR *StartofLine = ptr;
while (*ptr)
{
while (*ptr && !_istspace(*ptr))
{
ptr = _tcsinc(ptr);
++count;
}
if (count <= nWrap)
EndofLine = ptr;
if (!*ptr || count > nWrap)
{
ptr = EndofLine;
TCHAR temp = *ptr;
*ptr = 0;
lines.Add(StartofLine);
*ptr = temp;
StartofLine = _tcsinc(ptr);
count = -1;
}
if (*ptr)
{
ptr = _tcsinc(ptr);
++count;
}
}
strText.ReleaseBuffer();
}
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
PJ Arends wrote:
Honoured as one of The Most Helpful Members of 2004
And well deserved. Thanks, PJ!
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Hmm, the algorithm sometimes goes into an infinite loop. I worked out an alternate implementation which seems to work. Time will tell...
void wrap
(CString strString,
int nWrap,
CStringArray& lines)
{
int nStart = 0;
int nEnd = 0;
do {
nEnd = nStart + nWrap;
if (nEnd >= strString.GetLength())
nEnd = strString.GetLength() - 1;
if (nEnd != strString.GetLength() - 1)
while ((nEnd >= 0) && (strString.GetAt (nEnd) != _T(' ')))
nEnd--;
CString strNextLine;
if ((nEnd - nStart) > 0) {
strNextLine = strString.Mid (nStart, (nEnd - nStart) + 1);
lines.Add (strNextLine);
}
nStart = nEnd + 1;
} while (nStart < strString.GetLength());
return;
} /ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
PJ Arends wrote:
nWrap is the maximun number of characters in the line?
Yes, nWrap is the wrap boundary, i.e. the longest length of the resulting lines.
PJ Arends wrote:
Does lines have to be CPtrArray,
Gak! I told you I was sleep deprived.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Hi all,
I have a server and some clients,
I wamt a good solution to send messages to this
clients together.
Best Wishes,
Thanks.
|
|
|
|
|
|
Hello friends I've search in many post of this boards and the Articles, but a can't to find how I can to make the comunications with dialogs, for example I want to manipulate controls (list, Pages,...) of a Dialog One since other dialog two.
Please I somebody know about it, Answer this question.
The Best Regards
NiponWare
|
|
|
|
|
If you have not clicked on "Search comments", please do so at this time. The basic question you are asking has been asked severial time in the passed few months.
By now, someone may have wrote an article on it or placed it in a FAQ.
Well that's the best I can do right now, Good Luck!
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
This is easily done by passing a pointer to DialogOne to DialogTwo , thereby allowing DialogTwo to manipulate controls in DialogOne .
That being said, it's poor programming practice to simply modify controls in another dialog at whim. It's better (imho) that DialogOne expose well defined public methods to manipulate its controls. For example, if you want to repopulate DialogOne 's list control (m_someListCtrl ) member from DialogTwo , expose a method in DialogOne like this:
void repopulateListCtrl()
When DialogTwo wants DialogOne to reload its list control, it makes the following call:
DialogOne* m_pDialogOne = ptr to a DialogOne instance;
ASSERT (m_pDialogOne != NULL);
ASSERT (m_pDialogOne->GetSafeHwnd() != NULL);
ASSERT (::IsWindow (m_pDialogOne->GetSafeHwnd());
m_pDialogOne->repopulateListCtrl();
The implementation of DialogOne::repopulateListCtrl() method should PostMessage() a command to itself which causes the dialog's list control to be populated. This allows dialog specific UI actions to be properly serviced by each dialog's message queue.
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
Hello !
I want to know all the files that are inside a specific folder. Something similar to the CFileFind class in the MFC but WITHOUT using the MFC .
Are there some functions from the API I can use ??
Thanks
|
|
|
|
|
use _findfirst() and _findnext()
Steve
|
|
|
|
|
Wow, that was a quick response
Thanks, I will take a look at it but I think this is what I'm looking for
|
|
|
|
|
You can also use:
FindFirstFile (or FindFirstFileEx), FindNextFile, FindClose
INTP
"The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes."
Andrew W. Troelsen
|
|
|
|
|
hi guys
i need help on this real bad....
I have a MFC application dialog based.. has 2 dialog forms say dialog1 and dialog 2.. in dialog1 i have a picture holder (IDC_HOLDER). what i need to do is get the "Rect" value of that holder from dialog2 .. i can do that from dialog1 with
<br />
CRect rc;<br />
GetDlgItem(IDC_HOLDER)->GetWindowRect(rc);
but how to access that from dialog2....
my whole project has come to HALT by this ... please help .. someone !!!!!
thanks
zm
|
|
|
|
|
CDialog1* dlg1;
dlg1->GetDlgItem(IDC_HOLDER)->GetWindowRect(rc);
you may just create an instance of the first dialog and get a pointer to it like the above
|
|
|
|
|
should have mentioned that earlier.. i already tried that it doesnot work.. generates error.. tried to debug it and it fails right where i do
dlg1->GetDlgItem(IDC_HOLDER)->GetWindowRect(rc);
gives tis err msg.. Unhandled exception in rect.exe(MFC42D.DLL):0x..... Access Violation.
thanks for the suggestinon though....
can anyone have a solution for this ,
please . help mel...............
|
|
|
|
|
Of course it does. Code is using uninitialized pointer.
Instantiating another object is not going to help either since it will not be the same dialog that you are using.
In dialog 2 you would have to obtain pointer to existing dialog 1. once you have that pointer you can access any public member variable and function.
How to obtain this pointer depends very much where dialog 2 is created and what relationship (if any) exists between both dialogs.
Also modality plays role here.
JohnCz
|
|
|
|