|
|
Hi!
what is the smallest pointer address?
I think a pointer is never 1,2 (or 3)
to example :
void DrawDFText( LPSTR a) <br />
<br />
UINT i = (UINT) a;<br />
<br />
if ( i > 2 ) {<br />
TCHAR szBuf[180];<br />
wsprintf(szBuf, "address:%d ", a ); <br />
OutputDebugString( szBuf );<br />
return;<br />
};<br />
if ( i == 1 ) dothat1;<br />
if ( i == 2 ) dothat2;
it's right?
Regards!
Frigyes
|
|
|
|
|
Hi
Theoretically there is no smallest address a pointer can point to. In windows and c++ there is. But there is no need to know that value since you should never test against it. If you get a pointer like "LPSTR pStr" you should only check that its "!= NULL". Any thing else and you should assume that it’s a valid pointer. Its to job of the person giving you the pointer to be sure he gives you a valid one.
Also since this is c++ you really shouldnt use char arrays. Either use STL std::string or MFC CString when you need strings.
If you really want to know about how windows handles the memory and how pointers in it work. I can recomend the following book "Programming Applications for Microsoft Windows" by Jeffrey Richter[^]
Magnus
|
|
|
|
|
Hi Magnus!
many thanks for your answer!
> ... there is no need to know that value since you should never test it
but I must test it,
if I call my Drawtext procedure with 1 should start BeginPaint,
if I call with 2 should start EndPaint,
if NULL it's a error,
otherwise should be draw the text from the pointer,
(the procedure is a DLL procedure, and I can't use too many parameters)
can be the address from one pointer 1 or 2 ?
void __declspec(dllexport) DrawDFText( LPSTR a)<br />
{ ... }<br />
<br />
<br />
and call like:<br />
<br />
DrawDFText(1);<br />
<br />
DrawDFText("line1");<br />
DrawDFText("line2");<br />
...<br />
DrawDFText(2);
Regards!
Frigyes
|
|
|
|
|
Frigyes Nagy wrote: DrawDFText(1);
DrawDFText("line1");
DrawDFText("line2");
...
DrawDFText(2)
This is SO bad !!!
Why don't you create a function BeginPaint, EndPaint to do that explicitly ?
Frigyes Nagy wrote: the procedure is a DLL procedure, and I can't use too many parameter
Huh ?
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Hi!
I know, this is not really pretty, but it's works, and I never find any pointer address less then 1000.
(this is one DLL for my DATAFLEX program, I don't like to export 3 procs, if I can make the same work with a ugly one)
Regards
and sorry my english
Frigyes
|
|
|
|
|
Frigyes Nagy wrote: I never find any pointer address less then 1000.
There is a trick (a MACRO) found in the library to count the memory offset of the data member from the address of the struct which owns the data member.
It takes a pointer with the address = 0.
Maxwell Chen
|
|
|
|
|
Frigyes Nagy wrote: I never find any pointer address less then 1000.
Another instance to see the address less than 1000 is something like this way:
class MyTool<br />
{<br />
public:<br />
WORD MergeValue(BYTE hi, BYTE lo) {<br />
WORD wT = hi;<br />
return (wT << 8) | lo;<br />
}<br />
};<br><br />
MyTool* pTool = 0;<br />
WORD v = pTool->MergeValue(0x43, 0x21);<br />
Maxwell Chen
|
|
|
|
|
Hi!
thanks!
but this is to complex for me,
I speak from pointers to a string, allocated with new,
I can't imagine that they have address LT 1000, but ...
Regards
|
|
|
|
|
Frigyes Nagy wrote: wsprintf(szBuf, "address:%d ", a );
A pointer should be something like
UINT* pNum = &a;
And, to observe the address of the pointer, you should do this way:
sprintf(szBuf, "address: 0x%p \n", pNum);
Maxwell Chen
|
|
|
|
|
Hi!
thanks!
but LPSTR is also a pointer to a null-terminated string
This type is declared in Winnt.h as follows:
typedef CHAR *LPSTR;
void DrawDFText( LPSTR a) <br />
{<br />
<br />
sprintf(szBuf, "address: %d ", a); <br />
<br />
};
works for me...
Regards
Frigyes
|
|
|
|
|
Frigyes Nagy wrote: but LPSTR is also a pointer to a null-terminated string
I did not notice the first line about the function prototype...
Maxwell Chen
|
|
|
|
|
hi,
Is there any limitation on maximum number of threads a win32 process can spawn..??
Thanks,
|
|
|
|
|
nope... no hard limit. But you are going to run out of memory. Default each thread has a 1MB stack... so go from there. Also performance vise is that too many threads running (and doing stuff) you will start to loose so much time in the thread switches that the system will grind to halt.
Magnus
|
|
|
|
|
I don't think (so I'm not sure) there is a limitation to the number of thread an application can spawn. However, each thread need some resources to be maintained and there is a time sharing process which becomes inefficient if you have too many threads.
In brief, having a huge amount a thread will decrease a lot the performances of your app. In general, having so many thread results from a bad design.
|
|
|
|
|
Hi Everyone,
Can anyone tell me how to delete the entire selected row in a LISTCTRL using the keyboard delete key
Thanks in advance
With regards
Raja Bose
-- modified at 8:48 Tuesday 9th May, 2006
|
|
|
|
|
Capture the LVN_KEYDOWN message. You can then check to see if the key pressed is the delete key (VK_DELETE). If it is, then call your deletion routine as normal.
For e.g.
void CMyDialog::OnKeydownList(NMHDR* pNMHDR, LRESULT* pResult)
{
LV_KEYDOWN* pLVKeyDow = (LV_KEYDOWN*)pNMHDR;
switch( pLVKeyDow->wVKey )
{
case VK_F2:
ActivateEditing();
break;
case VK_DELETE:
OnDeleteitem();
break;
default:
break;
}
*pResult = 0;
}
I Dream of Absolute Zero
|
|
|
|
|
Hi,friends
Can anyody guide me about the secon round of interview
at microsoft. What they are genarally asked in that round ?
Rastogi
|
|
|
|
|
|
|
Try asking this in the Lounge, and good luck for the interviews.
~RaGE();
|
|
|
|
|
Hi,
How are you all?
This is my first post here. I am new to MFC and just a college passout.
I hope to have nice answers here for all the "Greats"!
My program is having memory leakage.
In my view function,
I use
CDC *pdc=GetDC()
But I am not releasing it.
Can this be a reason for leak?
In view function what is the best method to use Contect devices to avoid such errors? Should CClientDC be used?
I assume I am understandable here .
--
LinDaSu
|
|
|
|
|
Hi
What you have there is not a regular memory leak... it could be a GDI resource leak. But that is depending on how the window class is created. If any of the following styles were used CS_CLASSDC, CS_OWNDC or CS_PARENTDC, then the above is not a resource leak, other wise you should use ReleaseDC to reclaim the GDI resources.
Also for you information, VS C++ will not report GDI resource leaks only normal memory leaks from the built in memory handler.
Magnus
|
|
|
|
|
give me a sample for service in c++,mfc
|
|
|
|
|
Have you tried Googling for such an example?
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"We will be known forever by the tracks we leave." - Native American Proverb
|
|
|
|