|
that would not be so hard to find out by your self, isn't it ?
si, here is a starting point[^]. enjoy
|
|
|
|
|
<br />
int CChildView::OnCreate(LPCREATESTRUCT lpCreateStruct)<br />
{<br />
m_pQuickSearchDlg->Create(IDD_QUICK_SEARCH,this);<br />
return CWnd::OnCreate(lpCreateStruct);<br />
}<br />
When I use GetParent in CQuickSearchDlg, it returns a point of
CMainFrame. How can this be?
|
|
|
|
|
From VC help:
"
pParentWnd
Points to the parent window object (of type CWnd) to which the dialog object belongs. If it is NULL, the dialog object’s parent window is set to the main application window.
"
And in the hierarchie chart, CDialog hangs from CWnd, at the same level as the CView. So I find not so extrange that it gives the CMainFrame as parent.
If you want another result, wha don't you try to use SetParent in the OnInitDialog () ?
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
“The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson
|
|
|
|
|
Hi all,
I have a CString in binary values. I want to read it to find some data, not from the beginning. Say like this,
I want to skip first 8 bytes. Then read the next 16 bytes. Then skip next 5 bytes and read the rest. That mean I want to move the reading position of the CString on it. How can I do that.
I know that if I use a CFile I can use seek(). Is there any smiler way to do it.
I appreciate your help all the time...
Eranga
|
|
|
|
|
Rather than using CString use BYTE * or char *
Manish Patel.
B.E. - Information Technology.
|
|
|
|
|
Actually according to my application it is so easy to use as char *, as a buffer. Is it easy for my requirement?
I appreciate your help all the time...
Eranga
|
|
|
|
|
Take a look at the Mid function[^] (and similar functions like Right and Left
EDIT: BTW, in the documentation there's always the list of all available methods. And in general, the name of the functions are quite explicit.
|
|
|
|
|
Hmm, thats seems to me easy. I'll try it now. Let see. Thanks pal.
I appreciate your help all the time...
Eranga
|
|
|
|
|
Hello all,
I want to count perticular character in String.
I had made it by for loop but it takes to much time. Is there any in built function availale?
Thanks in advance.
Manish Patel.
B.E. - Information Technology.
|
|
|
|
|
If you want to get length of a string you can use of CString::GetLength().Is this your question?
|
|
|
|
|
No,
I am using BYTE * and i want to know how many times perticular char is repeated in that buffer.
Any idea?
Manish Patel.
B.E. - Information Technology.
|
|
|
|
|
Why are you using a BYTE array to store characters ? Do you need to store characters or unsigned characters ?
Can you post the code of your loop, because it shouldn't take too much time to check each character of your string (except if it is exceptionally long).
|
|
|
|
|
I am storing bytes in buffer. And its too long. Thats why i need for in built function.
Any idea?
i had done like this:
int countByte(BYTE *src, BYTE b)<br />
{<br />
int count = 0;<br />
for(int i = 0; i < strlen((char *)src); i++)<br />
if(src[i] == b)<br />
count++;<br />
return count;<br />
}
Any Suggestion..
Manish Patel.
B.E. - Information Technology.
|
|
|
|
|
Is your buffer NULL-terminated ? If no, then there is a big problem because strlen calculates the lenght of the string by counting the number of characters until it finds a 0.
|
|
|
|
|
Ya, My string is NULL terminated.
My function working properly but it takes to much time for string length greater than 10000.
Please provide me any idea to decrease this time.
Manish Patel.
B.E. - Information Technology.
|
|
|
|
|
//this one should run faster
int countByte(BYTE *src, BYTE b)
{
int count = 0;
int i = 0;
while( src[i] )
{
if(src[i] == b)
count++;
i++;
}
return count;
}
Greetings from Germany
|
|
|
|
|
Wow its working fine.
Thanks a lot.
Manish Patel.
B.E. - Information Technology.
|
|
|
|
|
It was taking so much time because at each iteration of your for loop, you call strlen. And strlen is basically just a loop that counts the number of characters until a 0 is encountered. So, redoing that at each iteration is quite costly.
|
|
|
|
|
<br />
typedef unsigned char BYTE;<br />
<br />
int countByte(BYTE *src, BYTE b)<br />
{<br />
int count = 0;<br />
BYTE *s;<br />
for (s=src;*s; s++)<br />
if (*s == b)<br />
count++;<br />
return count;<br />
} <br />
<br />
int _tmain(int argc, _TCHAR* argv[])<br />
{<br />
char s[20] = "111222333";<br />
printf("%d",countByte((BYTE*)s,'1'));<br />
return 0;<br />
}<br />
This version eliminates the strlen call and it eliminates the use of the square brackets []. Each time you use the square bracket array index, an offset into your array has to be calculated.
|
|
|
|
|
Hi Friends
I anybody have an idea to create a window, that is appeared in top of other windows. ie timeline slider in Windows Movie Maker
thanx in advance
-RisKhan-
|
|
|
|
|
You can use of SetWindowPos for set it to top.
|
|
|
|
|
thanks hamid. One more question, how to create a shapeless window. Do u have idea
thanks
-RisKhan-
|
|
|
|
|
|
when create a dialog based MFC project defaultly, we have the OK, cancel buttons in the topright corner, I want to create a CListBox dynamicly and place it in the position relative to the IDOK button( the top cordination of CListBox is the same as IDOK), so I write my code like below:
first, construct a CListBox in the .h file
CListBox m_ctlBox;
then, within the OnInitDialog
BOOL CMyDialog::OnInitDialog()
{
CDialog::OnInitDialog();
m_ctlBox.Create(STYLE, CRect(0, 0, 0, 0), rightcode);
m_ctlBox.ShowWindow(SW_HIDE);
CRect rcOK;
GetDlgItem(IDOK)->GetWindowRect(&rcOK);
int nBoxWidth = 30;
int nBoxHeight = 40;
int nxMargin = 10;
int nBoxTop = rcOK.top;
int nBoxLeft = rcOK.left - nxMargin - nBoxWidth;
m_ctlBox.SetWindowPos(&CWnd::wndTop, nBoxLeft, nBoxTop, nBoxWidth, nBoxHeight, SWP_SHOWWINDOW);
m_ctlBox.ShowWindow(SW_SHOW);
return TRUE;
}
but the m_ctlBox's top is not as IDOK's. Really confused with how to use GetClientRect 、GetWindowRect、ScreenToClient and ClientToScreen correctly to set window position correctly.
So I can't write my code to deal with WM_SIZE correctly.
|
|
|
|
|
GetWindowRect() gets coords relative to the screen.
SetWindowPos() is expecting coords relative to the parents client area.
BOOL CMyDialog::OnInitDialog()
{
CDialog::OnInitDialog();
m_ctlBox.Create(STYLE, CRect(0, 0, 0, 0), <font color="Red">this</font>);
m_ctlBox.ShowWindow(SW_HIDE); <font color="Green">
CRect rcOK;
GetDlgItem(IDOK)->GetWindowRect(&rcOK);
int nBoxWidth = 30;
int nBoxHeight = 40;
int nxMargin = 10;
<font color="Red"> CPoint BoxUpperLeft;
BoxUpperLeft.y = rcOK.top;
BoxUpperLeft.x = rcOK.left - nxMargin - nBoxWidth;
ScreenToClient(&BoxUpperLeft); <font color="Green">
</font> m_ctlBox.SetWindowPos(&CWnd::wndTop, <font color="Red">BoxUpperLeft.x</font>, <font color="Red">BoxUpperLeft.y</font>, nBoxWidth, nBoxHeight, SWP_SHOWWINDOW);
m_ctlBox.ShowWindow(SW_SHOW);
return TRUE;
} Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|