|
I'm not sure if an app that is running can be copied itself or even can be copied by other process...
|
|
|
|
|
It can - like this:
TCHAR szFileName[MAX_PATH];
::GetModuleFileName(szFileName, MAX_PATH];
LPCTSTR pszDest = _T("C:\\Program Files\\SomeApp.exe");
::CopyFile(szModuleFileName, pszDest);
|
|
|
|
|
look for [ShFileOperation] api!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
Hi guys,
I've developed in C++ for many years, but more recently have been working in C# and VB.NET.
I am developing my own version of themed controls where the user can govern just about any aspect of control drawing, like shape and colour etc.
I want to extend this control now to Windows Captions (i.e. Form captions). One thing that I have never fully gained is an understanding of what windows messages to trap, whether to let the default processing always take place, and what values to return. Even when I think I am following the MSDN SDK documention on WM_... notifications I still can't seem to get it right.
My problem seems to mainly be in getting setup, i.e. calling GetWindowDC to give me the entire drawing area of the window. Once I have called GetWindowDC I can construct a .NET Graphics object, and later dispose of both after my drawing is complete.
I do this and clear the Graphics object to red, so I should see all the non-client area turn red, which happens when the window is first drawn, but after that, as I start to move the window or size it I dont see the DC get consistently filled with red.
In summary then, if I could get a control of non-client drawing then I would have raised my programming standard significantly.
I would really be immensley greatful if you guys could point me at a definitive guide to subclassing or window's message processing, without recommending 3rd part controls as I am a DIY fanatic! 8-)
Also, if any of you can spare some time now and again, perhaps on MSN messenger to chat about this issue that would just be solid gold.
I await your responses with baited breath!
Thanks all!
Nursey
|
|
|
|
|
Override the OnMessage method which recieves a Message structure.
|
|
|
|
|
Thanks but I know how to get to the messages. As I said the problem has always been what messages to process. To be specific, what messages do I have to trap and process if I want to take entire responsibility for NC processing/drawing? Do I always have to perform the default processing then do my thing?
See?
Thanks.
Nursey
|
|
|
|
|
All,
History:
I have a list control that I used the onclick event to perform action with.
The user wanted to be able to use the up/down arrows so I changed the event handler to use the itemchanged message.
Now:
The user wants to use both the mouse and the arrows - which is fine since the itemchanged message takes care of both of these actions. The problem being that the user also wants to be able to reperform (if that's a word)
the same actions (it's a function to do a lot of number crunching on some data) on the currently selected item. The problem is that the itemchanged message gets called 3 times and thus the number crunching takes place 3 times!
How do I get this to handle both mouse clicks and up/down arrows without having my function called 3 times?
Thanks in advance,
John
|
|
|
|
|
the function is called three times for the selected and the item that is being unselected(if thats a word )
so i am going by memory here
it is called once when the previously selected item is Unselected, then for the new item that is selected and the the newly selected item gains focus rect
examin the NM_LISTVIEW structure that is passed it contains the ItemNo and the Reason(selected, unselected etc) and then perform ur action
Hope it helps
C makes it easy to shoot yourself in the foot; C++ makes it harder, but when you do, it blows away your whole leg
|
|
|
|
|
Like this (I think)
void CYourDialog::OnClickList2(NMHDR* pNMHDR, LRESULT* pResult)
{
LPNMLISTVIEW pnmv = (LPNMLISTVIEW) pNMHDR;
if(pnmv->uNewState & LVIS_SELECTED)
{
// do long running stuff
}
}
|
|
|
|
|
Thanks - that almost works...
It fails when I want to click on an already selected item and process data.
(I'm varying some algorithm params in the dialog and observing the effect).
So, I guess all I really want to do is to be able to use the up/down arrows to scroll and automatically process AND be able to use the mouse click to randomally select list data as well as process an already selected item.
Is this the correct approach (using these events or do I need to set and clear some global bool that I create to bypass all these cascading events?)
Thanks,
John
|
|
|
|
|
Yeah i don't think you get that event if you click on an already selected item... Have you tried processing NM_CLICK as well?
|
|
|
|
|
I have such block:
if (a > 0)
if (a > 255) b = 255;
else b = (BYTE)a;
else b = 0;
do anyone have an idea, how to make it works faster?
Thanx.
|
|
|
|
|
Not really faster, but certainly more obfuscated elegant:
b = a > 0 ? (a > 255 ? 255 : (byte)a) : 0;
~Nitron.
ññòòïðïðB A start
|
|
|
|
|
thanx, but i need fast, not elegant
such construction works even slowly.
|
|
|
|
|
Try it and benchmark it. I can say nearly for certain that little block of code is nowhere near a slight resemblance of your bottleneck. (of course that is if a and b are bytes or ints as you lead me to believe) Rule number 1 of optimization: Don't do it. Rule number 2: Don't do it _yet_.*
So... Unless a profiler is telling you your code is bottle-necking at that small comparator block, I suggest you worry more about the rest of your code and just leave what you have. Things like passing function args by value rather than by reference, useless construction and destruction of temporary objects derived from complex class heiarchies, and other such subtle things are nearly 100% of the time your bottleneck. (Save for things like disk/network IO, etc.)
*Herb Sutter - More Exceptional C++
~Nitron.
ññòòïðïðB A start
|
|
|
|
|
This block processing takes 3/4 of all code time.
|
|
|
|
|
Kolich wrote:
This block processing takes 3/4 of all code time.
no way! (unless your total processing time is like 0.000012 seconds). How long is your processing time? How many elements in your matrix? Here is the disassembly for my test block:
if (a > 0)
00411ADE mov eax,dword ptr [a]
00411AE1 cmp dword ptr [eax],0
00411AE4 jle test+48h (411B08h)
if (a > 255)
00411AE6 mov eax,dword ptr [a]
00411AE9 cmp dword ptr [eax],0FFh
00411AEF jle test+3Ch (411AFCh)
b = 255;
00411AF1 mov eax,dword ptr [b]
00411AF4 mov dword ptr [eax],0FFh
else b = a;
00411AFA jmp test+46h (411B06h)
00411AFC mov eax,dword ptr [b]
00411AFF mov ecx,dword ptr [a]
00411B02 mov edx,dword ptr [ecx]
00411B04 mov dword ptr [eax],edx
else b = 0;
00411B06 jmp test+51h (411B11h)
00411B08 mov eax,dword ptr [b]
00411B0B mov dword ptr [eax],0
that's like 16 instructions! It probably takes more just to instantiate one of your matrix objects...
~Nitron.
ññòòïðïðB A start
|
|
|
|
|
basic time takes operation b=a.
its bad.
|
|
|
|
|
you find this elegant ?????????
i agree the ?: operator is elegant when you have few (less than 2) conditions, but it becomes really unreadable otherwise.
more, it uses exactly the same time as the previous post's code. what i prefer is expanding the code, but placing the { }. it doesn't eat bread and it is really more easy to debug.
one last thing. the first written code is (by my thinking quite fast). you can so let it like this :
<font style="color:blue;">if </font>(a > 0) {
<font style="color:blue;">if </font>(a > 255) {
b = 255;
}
<font style="color:blue;">else</font> {
b = (BYTE)a;
}
}
<font style="color:blue;">else </font>{
b = 0;
}
TOXCCT >>> GEII power
|
|
|
|
|
|
Nitron wrote:
I see you are a same-line bracer
where, which ? what is wrong in my code ?
i don't exactly understand your sentence. could you rephrase it please ?
TOXCCT >>> GEII power
|
|
|
|
|
You do this:
if (a > 0) {
if (a > 255) {
b = 255;
}
else {
b = (BYTE)a;
}
}
else {
b = 0;}
instead of this:
if (a > 0)
{
if (a > 255)
b = 255;
else
b = (BYTE)a;
}
else
b = 0;
i.e. you put your opening braces on the same line as your conditional statement.
~Nitron.
ññòòïðïðB A start
|
|
|
|
|
and so what ??? didn't you ever saw that ?? is it a code fault ? pfffffff poor guy.
moreover, i said that it was more readable to write the code with the braces. when you cat multiple if statements, we are not sure to whose if the esle is associated with.
My code is correct, if you don't like this, it's your point of view, but it is efficient !
TOXCCT >>> GEII power
|
|
|
|
|
dude, chill. The code is fine, I was just giving you a hard time. I guess I know how to push your buttons
~Nitron.
ññòòïðïðB A start
|
|
|
|
|
If you can also provide us with the data types of a and b , then may be we can find out some idea. And if you can explain what you are actually trying to do, that would be much better.
Gurmeet BTW, can Google help me search my lost pajamas?
My Articles: HTML Reader C++ Class Library, Numeric Edit Control
|
|
|
|