|
On which function of your dialog is this code inserted?
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
|
You're calling MoveWindow before it has an h_Wnd
try this;
<br />
if(GetDlgItem(IDC_BTNADDITEM)->m_hWnd)<br />
MoveWindow(rect);<br />
|
|
|
|
|
Sorry, I meant for it to be this:
if(::IsWindow(GetDlgItem(IDC_BTNADDITEM)->m_hWnd))
MoveWindow(rect, TRUE);
Are you calling it from OnSize? I did this in my own code, and when it is resized when it is initially displaying it, I guess it doesn't have an m_hWnd. If it still doesn't work, use class wizard to create a class for it (control class) then use that to get the m_hWnd
Josh
|
|
|
|
|
That worked, thanks! I just had to change m_hWnd to GetSafeHwnd(), it causes an access violation if you use m_hWnd.
This brings up another question. I am resizing in the code below, which does center the button horozontally and keeps the button at the same place vertically.
<br />
CRect rect;<br />
<br />
rect.left = cx - (415 + 102);<br />
rect.right = rect.left + 40;<br />
rect.bottom = cy - 40;<br />
rect.top = rect.bottom - 14;<br />
<br />
if(::IsWindow(GetDlgItem(IDC_BTN_ADD)->GetSafeHwnd()))<br />
GetDlgItem(IDC_BTN_ADD)->MoveWindow(rect, TRUE);<br />
In the code above, I specify 40 to be the width of the button, and the 14 to be the height. But when the button is drawn, the button appears to be 10 in height, if it were drawn in the resource editor, and the width appears to be about 25. Is there way to adjust this, so the button appears like it would in the resource editor, that is, with a height of 10 and a width of 40?
|
|
|
|
|
For grins, try using the other version of MoveWindow() and specify the width and height in the parameters, and seee if that works.
Josh
|
|
|
|
|
I tried it, and it still produced buttons which are too small. At the risk fo sounding dumb (which isn't uncommon for me ) I always assumed that the resource editor and code functions all used the same units (pixels). If they are not the same, is there a formula or ratio to convert resource editor units to code units, so to speak?
|
|
|
|
|
May be try this
GetDlgItem(IDC_BTN_ADDITEM)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_BTN_ADDITEM)->MoveWindow(rect);
GetDlgItem(IDC_BTN_ADDITEM)->ShowWindow(SW_SHOW);
|
|
|
|
|
Is there a specific code for MS C++ 6.0 to find the length of the FIRST word in ANY string.
Ex: (This is my sentence)
The length of the first word is 4.
Thank you
|
|
|
|
|
Use strtok:
LPCTSTR szSentence = _T("This is the stuff.");
LPCTSTR pszWord;
pszWord = _tcstok ( szSentence, _T(" ") );
--Mike--
"Everyone has figured out what 'service pack' really means, so they had to go and change the language. Perhaps this is what Bill was talking about in the 'security is top priority' letter."
-- Daniel Ferguson, 1/31/2002
My really out-of-date homepage
Sonork - 100.10414 AcidHelm
Big fan of Alyson Hannigan.
|
|
|
|
|
http://www.codeproject.com/string/tokenizer.asp
<br />
CTokenizer tok("This is my Sentence", " ");<br />
CString sen;<br />
<br />
if(toh.Next(sen))<br />
sen.GetLength();<br />
<br />
Think this is right
Josh
|
|
|
|
|
Another method, if you happen to like iostream s:
std::string sentence="One ring to bind them all";
std::string first_word;
std::istringstream(sentence)>>first_word;
std::string::size_type length_first_word=first_word.size();
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hey all.
new/delete in there default implementation use the default heap returned by GetProcessHeap()(????)
If this is correct, does this mean I could manually detect memory leaks by comparing the HeapSize at startup to HeapSize at destruction...?
What about detecting GDI, or Virtual, GLobal, Malloc memory leaks...?
Can I use GlobalMemoryStatus() again to find the difference of memory useage(Would indicate memory leakage???) at startup and destrcution...? This probably wouldn't be that accurate huh...? How do tools like Stress return there values, is this an example of GlobalMemStatus()...?
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
new/delete uses a private heap, so I'm afraid GetProcessHeap won't do. Fortunately, in debug mode you can use <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore98/html/_crt__crtmemdifference.asp">_CrtMemDifference</a> and related functions (in <crtdbg.h> ) to check for memory leaks caused by C run-time library allocations (malloc , realloc and new ).
As for other functions that also allocate memory, I don't know (right off the top of my hat) of any easy method to detect leaks.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Thanx again Joaquín.
This will do for now...
Cheers
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
Hello,
I have problems in one of my applications (others are very similar and without this problem).
The problem is:
When I run application I've got ASSERTION FAIL in file DOCSINGL.CPP at line 216
// use generic 'untitled'VERIFY(strDocName.LoadString(AFX_IDS_UNTITLED));
I don't know why it cannot find string with ID AFX_IDS_UNTITLED. If I define it manualy in a string table, I can run just a Debug version. A Release version give me unhandled exception in KERNEL32.dll
I included all standard files(afxres.rc,...).
Can anybody help me please?
Thanks
Peter
|
|
|
|
|
Try with the "Rebuild all" command. Sometimes the dependency engine goes nuts and plays little tricks like that.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
|
I am trying to copy the contents of the returned value of this function into a variable:
LPWKSTA_INFO_100 pBuf = NULL;
NET_API_STATUS nStatus;
nStatus = NetWkstaGetInfo(NULL, 100, (LPBYTE *) &pBuf);
But I do not want to specify any hardcoded sizes and I do not want to use any CString or strings. what's the best way of doing it? the only thing I have managed to get so far is this:
wsprintf(tcUser, "%200S", pBuf->wki100_computername);
but I am still specifying a size. Any other ways of doing this?
|
|
|
|
|
CString str;
str = _T(pBuf->wki100_computername);
Regards...
Carlos Antollini.
Sonork ID 100.10529 cantollini
|
|
|
|
|
Probably something like this:
TCHAR* name = new TCHAR[lstrlen(pBuf->wki100_computername)];
lstrcpy(name, pBuf->wki100_computername);
Of course, don't forget to delete[] name.
CodeGuy
The WTL newsgroup: over 1100 members! Be a part of it. http://groups.yahoo.com/group/wtl
|
|
|
|
|
how about memcpy?
I was wondering if I use memcpy, how do I get the string length of the second member of the structure which is pBuf->wki100_computername as my attempts in using strlen and its variations haven't been successful?
|
|
|
|
|
There shouldn't be any reason why strlen/lstrlen wouldn't work unless you are having a syntax problem or a more serious coding problem.
Tim Smith
Descartes Systems Sciences, Inc.
|
|
|
|
|
Well, first off you've got a problem in that you're passing the address of a pointer to the API, not the address of a WKSTA_INFO_100 struct. That's gonna corrupt your stack.
Once you fix that, use ATL's W2CT macro to convert from WCHARs to TCHARs, then _tcsdup to make a copy of the string.
USES_CONVERSION;
LPCTSTR pszCompName;
pszCompName = _tcsdup ( W2CT(buf.wki100_computername) );
if ( NULL == pszCompName )
free ( pszCompName );
--Mike--
"Everyone has figured out what 'service pack' really means, so they had to go and change the language. Perhaps this is what Bill was talking about in the 'security is top priority' letter."
-- Daniel Ferguson, 1/31/2002
My really out-of-date homepage
Sonork - 100.10414 AcidHelm
Big fan of Alyson Hannigan.
|
|
|
|
|
Hi,
I created a MDI app with a CRicheditView.
Works fine but I'd like to modify the Richedit style, i.e. add auto horizontal scroll to avoid line wrapping.
usualy, this is done through create(style, .....).
But I can't find where the richedit is created in the MDI appwizard generated code
help !
|
|
|
|