|
This is just another way of exploiting power of pointers provided by C++. But this is not considered as good practice.
|
|
|
|
|
ABuenger wrote: Actually I would even say it is better than creating a new object and calling the constructor which makes a copy of the pointer.
This is an illusion. Firstly note that sizeof(CIntPtr*) == sizeof(CIntPtr) . This means that, from a storage point of view, there is no difference. i.e.
class CIntPtr
{
public:
CIntPtr(int *pInt = NULL) : m_pMyInt(pInt) {}
void AddOne () { (*m_pMyInt)++; }
int *m_pMyInt;
};
int myInt = 0;
int *myIntPtr = &myInt;
CIntPtr *myIntWrapper = (CIntPtr*)&myIntPtr;
CIntPtr myOtherWrapper(&myInt);
In short the advantages of this confusing technique may be imagined.
Steve
|
|
|
|
|
Hi all,
Has anyone encountered some VERY STRANGE problems with layered windows, when using the CWnd::UpdateLayeredWindow() API call?
I have had success and failures using the SAME call from within the constructor of my CWnd derived class. My "success" is determined by the classname used when the window was created.
I'm calling UpDateLayeredWindow() this way:
BOOL bResult = UpdateLayeredWindow( NULL, &ptDest, &size, &mem,<br />
&ptSrc, byAlpha, &m_Blend, ULW_ALPHA);
Note "mem " is a screenCompatible CDC, on which a bitmap was drawn via code(simple rectangular fill), and size is the size of the CBitmap object selcted into the mem CDC.
1) Partial success if created using -
CWnd::CreateEx(WS_EX_LAYERED |WS_EX_TOPMOST|WS_EX_TOOLWINDOW, "STATIC",<br />
_T(""),WS_VISIBLE|WS_POPUP, 300,300,200,200,NULL, NULL, NULL );<br />
my window appears, but doesn't receive mouse events.
2) Failure, if I create it using:
CreateEx(WS_EX_LAYERED |WS_EX_TOPMOST|WS_EX_TOOLWINDOW, m_lpszClassName,<br />
_T(""),WS_VISIBLE|WS_POPUP, 300,300,200,200,NULL, NULL, NULL );
where
m_lpszClassName = AfxRegisterWndClass( CS_VREDRAW | CS_HREDRAW | CS_OWNDC );
The bitmap does NOT appear. I have to do a bitblt of the mem to screen to see it appear, preceded by a MoveWindow call. But then I receive mouse events.
I find this baffling. Does anyone else have any insight into this situation?
Thanks for anything info you can provide!
Jeanne Sim
-- modified at 19:22 Thursday 15th June, 2006
|
|
|
|
|
Hello,
When you define in some function a critical section you define a critical section block or variable ?
I will explain - when some thread get to this Critical section and the Critical section is lock - so this thread will go sleep until this Critical section will be unlock and the event will be called to rise up.
But my problem (or my bad understanding) is about the block of the critical section - i think that the critical section is only to block thread and make the thread sleep and have no direct connection to the block - but some other thought is that the critical section is define only on block.
Can someone explain the main idea of the critical section in this case ?
Thanks on any help.
|
|
|
|
|
There are numerous good articles about this:
Check Here.[^]
----------
Some problems are so complex that you have to be highly intelligent and well informed just to be undecided about them.
- Laurence J. Peters
|
|
|
|
|
yanshof wrote:
Can someone explain the main idea of the critical section in this case ?
See here.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I read those both and i still have the same question.
My question will not appear in there.... like i said this is hard question...
|
|
|
|
|
yanshof wrote: I read those both and i still have the same question.
Why? What part did you not understand?
yanshof wrote: My question will not appear in there....
Maybe not directly, but you can easily infer the answer.
yanshof wrote: When you define in some function a critical section you define a critical section block or variable ?
A critical section is a block of code (that can contain variables).
yanshof wrote: Can someone explain the main idea of the critical section in this case ?
The link I provided you explained this in detail.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
yanshof wrote: - i think that the critical section is only to block thread and make the thread sleep and have no direct connection to the block - but some other thought is that the critical section is define only on block.
I'm not sure I follow..
A CRITICAL_SECTION variable is an opaque object which holds a lock state. It's not a handle to anything, like mutexes are (they are kernel objects). I'm not sure what you mean by block, but I'm going to assume it's a body of code such as { ... } . A critical section is not automatically associated with such a block. The state of the critical section object is determined by the Enter/Leave functions, and can span over any number of blocks.
--
100% natural. No superstitious additives.
|
|
|
|
|
A critical section is a small section of code that requires exclusive access to some shared resource before the code can execute. To protect that section of code we need to encapsulate that code in EnterCriticalSection and LeaveCriticalSection function call.
Better avoid using 'block' terminology.
|
|
|
|
|
In MFC-speak that would be a CCriticalSection object along with a CSingleLock object.
|
|
|
|
|
Does anyone know of a way to take an existing VC project and clone it to another directory with a new name. The project file would be re-named, along with the cpp files.
Captain, I must protest, I am NOT a merry man.
|
|
|
|
|
Did menually before, by renaming source files and modifying these project files:
.dsw
.dsp
.rc
These files can be opened and changed in any text editor.
- It's easier to make than to correct a mistake.
|
|
|
|
|
vc provides one method.
build new project, select "Custom AppWizard",input new project name.ok
show "Custom AppWizard - Step 1 of 2", select "an existing Project",
next, show "Custom AppWizard - Step 2 of 2",
now notice select yourself project (*.dsp),finish.
build...
now it will bring "*.awx" and "*.pdb". then copy they to
vc install directory common\msdev98\template.
now you build new project, use "AppWizard", you find new item.
alantop
|
|
|
|
|
Terms:
Ext: Computer which to which I can connect using telnet.
Local: My personal computer.
MyApp: Application which runs on Local.
Problem:
I would like to control an application on Ext. using MyApp running on Local. One way I can think of doing this is to open a command console, CC1 on Local, and telnet into Ext. If I then redirect the input/output from MyApp (running in a second command console, CC2) to CC1, I can accomplish this task. The windows utilities GetStdHandle and WriteConsole look like they could be useful here. I am familiar with C but new to windows programming,
so I don't know if this strategy is a good approach, or perhaps there may be a much better way to accomplish this task (TCPIP server?)
Any suggestions would be appreciated.
Thanks.
|
|
|
|
|
Have you considered Remote Procedure Call (RPC)? There's also Remote Execute (REXEC).
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I did not consider RPC, and think this might be a good solution. Am studying this.
|
|
|
|
|
Good to hear people still use RPC (which is much simpler than COM!)
- It's easier to make than to correct a mistake.
|
|
|
|
|
|
See here.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Have you tried Rent-A-Coder? That site handles work-for-hire, and might even help out with homework.
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
lulu0441 wrote: do it in C++
So, just do it.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
Maximilien wrote: So, just do it.
The Nike folks are going to be all over you for saying that!
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Ok, you want C++ this time?
void main()
{
Cout << "I'm trying to cheat on my homework, but am too stupid to avoid being caught.";
}
|
|
|
|
|
i am currently trying to make my program copy or move itself into my "programs to test " folder, by itself. I have been fooling around with trying ot use the shellexecute to move it but have found it easiest to use a Code to do it. My MAIN problem is that in order to make the program move itself, i need it'd current file path (i.e. c:\\Documents and Settings\\Droz\\My Documents\\Program.exe)
I have been trying to use GetFilePath, GetSystemDirectory and GetFullFilePath and still have not been able to make it work.
Breaking it down, i need the program to be able to know and be able to print out to the user its current location.
Thank you for any help. Happy programing.
- Droz -
___ ___
/\/\ /\ | |
|
|
|
|