|
I've been looking at the documentation of GetSafeHwnd()
it was attached to a member variable of a window.
ex. m_csEdit.GetSafeHwnd(param1,param2) ;
It can make it work for controls within my Dialog box but
not with a Dialog box itself.
Would someone be able to show me a skeleton code?
I need to get a handle of the only Dialog box I have
created by Appwizard(my program is Dialog Based).
Thanks everyone
|
|
|
|
|
Hiya I have a string in a file e.g
char buffer[] = "mike,jones,28,accountant";
and 4 variables: char FirstName[30],Surname[30],Age[30],Occupation[30];
What I am trying to do is split up the string and store each field in its relevant variable i.e store mike into FirstName and so on.
I have actually done this and it works fine but it is a very long winded approch. e.g
pDest = strchr( buffer,ch );
position = (int)( pDest - buffer );
for( i=0;i
|
|
|
|
|
If you use MFC, you may try AfxExtractSubString (the undocumented function declared in afxwin.h ).
If you don't, it would be wise to write a parser class instead of putting clumsy inline code into your application itself.
Regards,
BB
|
|
|
|
|
|
hello
i creat a vector in class named foufou vector< foufou * > fou_caracter; and in an other class i store in the vector a random position that i generat
by rand
void creatfoufou::creatfou(int amount)<br />
{<br />
foufou *newfoufouPtr;<br />
<br />
int speed,steer;<br />
<br />
for(int index=0;index<amount;index++)<br />
{<br />
<br />
<br />
ptrfoufou->initPosX =( ( 1 + rand( ) % 100 ) - 50 );<br />
ptrfoufou->initPosY =( ( 1 + rand( ) % 100 ) - 50 );<br />
ptrfoufou->initPosZ =( ( 1 + rand( ) % 100) - 50);<br />
<br />
newfoufouPtr = new foufou();<br />
fou_caracter.push_back( newfoufouPtr );<br />
<br />
<br />
<br />
<br />
}<br />
}<br />
<br />
and in an other function i want read the vector but i don't can
void creatfoufou::iteratorVector()<br />
{<br />
<br />
creatfou(5);<br />
int vectorIndex;<br />
vectorIndex = fou_caracter.size();<br />
<br />
for (int i=0;i<vectorIndex ;i++)<br />
{<br />
<br />
ptrfoufou->RePaint(<br />
fou_caracter[i]->initPosX,<br />
fou_caracter[i]->initPosY,<br />
fou_caracter[i]->initPosZ);<br />
}<br />
<br />
<br />
}
what is the error with this???
|
|
|
|
|
Your loop is not correct!
for( int i=0; i < vectorIndex; i++ ) and do not use (->) to access fou_caracter!
|
|
|
|
|
sorry
can you precise i don't understand very well what i must use to access to fou_caracter,because it my first time to use the vector
|
|
|
|
|
Hi,
I use the msdn code for getting multiple lines in a CEdit to a CString and it works great. But my problem is when a line have only 1 character the CString value return by the code below do not have the corresponding character but a \0 (i think, well it's like a \t or \r or \n in the debug, it's a square)
This is the code I use (line is return in strText)
int n = TempEditM->GetLineCount(); // Récupère le nombre de lignes
for (int i=0;i<n;i++)
{
int="" len="TempEditM-">LineLength(TempEditM->LineIndex(i));
TempEditM->GetLine(i, strText.GetBuffer(len), len);
strText.ReleaseBuffer(len);
}
Can you help me please ?? Thanks you very much
|
|
|
|
|
I think what you are seeing is the 'soft line-break' character but I could be wrong.
You can view the memory:
LPTSTR szBuffer = strText.GetBuffer(len);
TempEditM->GetLine(i, szBuffer, len);
strText.ReleaseBuffer();
ÿFor the bread of God is he who comes down from heaven and gives life to the world. - John 6:33
|
|
|
|
|
hi,
The value of the character is 0x01... But i'd like to have the right character. For exemple, if my edit box ahve the lines :
abcdefghijklmnop
q
The first return is strText is : "abcdefghijklmnop"
and the second is : char(0x01) but not "q"
Do you know why i get this 0x01 instead of the "q" ??
Thank you .
|
|
|
|
|
well, I had some check in my code :
int n = TempEditM->GetLineCount(); // Récupère le nombre de lignes
for (int i=0;i<n;i++)
{
="" int="" len="TempEditM-">LineLength(TempEditM->LineIndex(i));
if (len!=1)
{
TempEditM->GetLine(i, strText.GetBuffer(len), len);
strText.ReleaseBuffer(len);
}
else
{
TempEditM->GetLine(i, strText.GetBuffer(len+1), len+1);
strText.ReleaseBuffer(len+1);
}
}
and it work
thanks you, bye
|
|
|
|
|
Hi!
I'm using the new HTMLEdit classes introduced in VS.Net. I'm writing a Html Edit programm that allows the user to create tables.
I've a question about the selection of the cells: is it possible de change a property (or add some extra code) so that the user can select cell by cell like on a spreadsheet? (ie extend the selection). For now, when a user try to select cells, all the row is selected......
Thks in advance!
Appstmd
http://www.appstmd.com
|
|
|
|
|
I'm experimenting with hooking, but when I do the following:
hWndsHook = SetWindowsHookEx(WH_CBT, (HOOKPROC)CBTProc, NULL, NULL);
I expect it to run:
LRESULT CALLBACK CBTProc(int nCode, WPARAM wParam, LPARAM lParam)
{
if (nCode == HCBT_CREATEWND)
{
HWND hWnd = reinterpret_cast<HWND>(wParam);
LPCBT_CREATEWND lpcw = (LPCBT_CREATEWND)lParam;
LONG lpCreateParams = (LONG)lpcw->lpcs->lpCreateParams;
::SetWindowLong(hWnd, GWL_USERDATA, lpCreateParams);
}
return CallNextHookEx(hWndsHook, nCode, wParam, lParam);
}
But it doesn't. There are no compile warnings or whatsoever. I tried to debug it, but when marking it with a breakpoint (at CallNextHookEx) for example, it doesn't break, and it sure doesn't do what I want it to do. And I really am creating windows with CreateWindow, which does do what it needs to do (The MessageLoops work).
LPCTSTR Dutch = TEXT("Double Dutch ");
|
|
|
|
|
Did you check the return value of SetWindowsHookEx ?
If you specify a thread id NULL, you handle must be valid, and it must be inside of a DLL. If you want to hook your own application, than you must call GetCurrentThreadId() . By the way, hook are pretty difficult to debug. That's the reason for WH_DEBUG !
Hope that helps, Good luck!
ÿFor the bread of God is he who comes down from heaven and gives life to the world. - John 6:33
|
|
|
|
|
Well, when I wrote the thing and uploaded it, in a minute I knew the solution, It works great.
The function looks like:
static LRESULT CALLBACK CBTProc(int nCode,
WPARAM wParam,
LPARAM lParam)
{
if (nCode == HCBT_CREATEWND)
{
LONG counter = 0;
HWND hWnd = reinterpret_cast<HWND>(wParam);
LPCBT_CREATEWND lpcw = (LPCBT_CREATEWND)lParam;
LONG lpCreateParams = (LONG)lpcw->lpcs->lpCreateParams;
if (lpCreateParams != 0 && lpcw->lpcs->hInstance == __hInstance__)
{
for (iIterator = arrUnboxedClasses.begin(); iIterator != arrUnboxedClasses.end(); iIterator++, counter++)
{
if (arrUnboxedClasses.at(counter) == lpCreateParams)
{
::SetWindowLong(hWnd, GWL_USERDATA, lpCreateParams);
goto end;
}
}
}
}
end:
return CallNextHookEx(__hWndsHook__, nCode, wParam, lParam);
}
I still think that another application may not crash because I install a hook, this is not a really good design, I think.
LPCTSTR Dutch = TEXT("Double Dutch ");
|
|
|
|
|
Friends i need to know about the overhead involved in a function call w.r.t Visual C++ compiler.
Actually i am writing a server based aplication in which speed and efficiency are the primary requirements. There is a function in my program which makes some complex calculations. This function is called by a for loop about 150 times. I also make this function inline function, but i've read in number of C++ docs that making a function inline is of no guarantee that compiler really makes it inline and it depends on a compiler to decide whether to "paste" the code or to keep it a separate function.
So i am in confusion that in my application, a loop is calling the function 150 times and if too many clients send request and i call this function 150 times for each request then there will be lots of CPU cycles required which decreases the efficiency of my application.
So what do you people suggest me to do? Please also tell me the cost involved in calling a function and also tell me how can i judge that the compiler really makes my function inline or not ??
Thanks
|
|
|
|
|
Don't worry about it. From your description, the process of setting up a new stack and calling a subroutine isn't the bottleneck. Removing those steps would not gain any significant time compared to the big complex function.
--Mike--
Eh! Steve!
Homepage | RightClick-Encrypt | 1ClickPicGrabber
"You have Erica on the brain" - Jon Sagara to me
|
|
|
|
|
A function call will take up CPU time, however it is very minimal as compared to what you are doing inside the function.
Bringing the function inline could actually make the operation slower under certain circumstances since it could change the optimization.
All this is mostly irrelevant since optimizations shouldn't be based on theory but on measurable results always keeping in mind the adage that 90% of your time is spent in 10% of your code. Also, the algorithm itself is more important than the implementation.
(By chance I was doing some optimizing this morning. So I modified the test a little and found that making an intermediate function call added about 8 CPU cycles per call on a Celeron 900. The result with the new algorithm was still 4x faster than the original algorithm.)
PS. You could use the keyword __forceinline if your test show that this will improve performance.
|
|
|
|
|
Well, I know someone who makes a 3D-graphics engine, it really does matter pushing things on the stack or not. So I think a compiler should just inline when you want it to inline. Which doesn't gain much over complex calculations, but simple calculations, at the other hand, do matter.
LPCTSTR Dutch = TEXT("Double Dutch ");
|
|
|
|
|
S van Leent wrote:
it really does matter pushing things on the stack or not
It MAY matter, performance wise. If speed is of most importance, a developer may choose to use the __fastcall modifier on functions. However, if speed is that important, you should always test your code, not simply presume it is faster one way over the other.
S van Leent wrote:
So I think a compiler should just inline when you want it to inline.
I totally disagree. The standard is quite correct in this regard. For convenience, or when using templates, developers may implement a member function in the header, either explicitly inline or within the body of the class definition. If all of those are automatically inlined, it will result in bloated code and may very well result in slower code. (Beyond CPU cycle counts, bloated code will result in more paging which will have a devastating effect on performance.)
In general, unless you really understand the CPU architecture, you should just write clean C/C++ code and let the compiler do it's thing.
Again, most performance bottlenecks are in a tiny part of the code and can often be fixed by using a better algorithm and in understanding and leveraging the OS better.
|
|
|
|
|
Joe Woodbury wrote:
In general, unless you really understand the CPU architecture, you should just write clean C/C++ code and let the compiler do it's thing.
I agree with that, also, I think Inlining is sometimes a lazy way of writing a macro, which is (the macro) sometimes much better.
LPCTSTR Dutch = TEXT("Double Dutch ");
|
|
|
|
|
Joe Woodbury wrote:
By chance I was doing some optimizing this morning. So I modified the test a little and found that making an intermediate function call added about 8 CPU cycles per call on a Celeron 900.
Can you please tell me what method you normally use to find out the number of CPU cycles involved in a function call ???
|
|
|
|
|
At the core, you use the rdtsc x86 instruction. The actual sequence is:
ULARGE_INTEGER cycles;
if (!m_onNT)
_asm cli
_asm
{
pushad
cpuid
rdtsc
mov cycles.HighPart,edx
mov cycles.LowPart,eax
popad
}
if (!m_onNT)
_asm sti
You then calculate the overhead of the base test and then time the tests and do analysis (I throw away the top and bottom 20% of the results and average the rest.) You can also calculate the actual speed of the CPU and convert the cycles into seconds. I only do this if I really need to know the time in seconds, otherwise, I just compare cycles.
There are classes posted in CodeProject to help with all this, though I use my own.
|
|
|
|
|
Shah Shehpori wrote:
but i've read in number of C++ docs that making a function inline is of no guarantee that compiler really makes it inline and it depends on a compiler..
In Visual C++ you can use the __forceinline keyword (which is a Visual C++ specific keyword as the double underscore suggests) to force the compiler to compile it as an inline function, again there are restrictions to this but I don't think that'll be the case for you. You can read further in MSDN.
Edit: Oops sorry it was already suggested above. I guess the force is not with me then.
|
|
|
|
|
What caused WSAECONNRESET error?I'm trying to send some data(jpeg file) to my SMTP server,but at the middle of sending this error happend.Any idea?
Mazy
No sig. available now.
|
|
|
|