|
Thanks its help me ,now its done.
tnaks alot
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
Randor wrote: One option is to use the FindWindow Function[^]
That is a bad option because the window caption of the app's window can change (File name added, etc.) or you can run into race conditions when two instances of the app are started almost simultaneously. See Avoiding Multiple Instances of an Application[^] for a complete discription and a proper soloution to this problem.
You may be right
I may be crazy
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|
|
Hi PJ,
The original poster is not asking how to avoid multiple instances of his application. He has apparently solved this issue with a mutex. The question was how to bring the previous instance of his application to the top.
I respect Dr. Newcomer but many of his articles are written for the Win98 era and some of them are simply outdated and do not apply to recent Microsoft operating systems. See for example:
http://www.codeproject.com/Messages/2455189/Re-How-do-I-prevent-multiple-instances-of-my-program.aspx[^]
Best Wishes,
-David Delaune
|
|
|
|
|
But he does point out the reason why FindWindow() is not an appropriate method to find the first instance of the app. He also illustrates a method using EnumWindows() and SendMessageTimeout() to better accomplish the desired task. That is the reason I linked to his article.
You may be right
I may be crazy
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|
|
PJ Arends wrote: But he does point out the reason why FindWindow() is not an appropriate method to find the first instance of the app.
Hi PJ,
You are correct. In retrospect I think Supermans idea of using CreateEvent/SetEvent would be the best option. I just spent the last 15 minutes using WinDbg to step through calls to FindWindow in the user32.dll that shipped with Windows7. It appears that FindWindow has the same behavior as previous versions of Windows in that it results in the call to SendMessageW which could potentially result in a deadlock.
PJ Arends wrote: He also illustrates a method using EnumWindows() and SendMessageTimeout() to better accomplish the desired task
I have reviewed his code and determined that it does not handle modality. His code should call GetLastActivePopup or ShowOwnedPopups. Even this technique has some disadvantages...
Superman's idea is superior in every respect. It would allow the previous instance to respond to the event and activate its own windows.
Thanks for your comments PJ!
Best Wishes,
-David Delaune
|
|
|
|
|
Recently,I'm learning how to make custom UI,by using BitBlt() put some bitmap to DC.When comes to 'Compatible DC' and 'Compatible Bitmap',i'm confused about codes as follows:
codes in function OnPaint():(VC++)
CDC memDC,tempDC;
CClientDC dc(this);
CBitmap memBmp;
CRect rcClient;
GetClientRect( &rcClient );
memDC.CreateCompatibleDC( &dc );
tempDC.CreateCompatibleDC( &memDC );
memBmp.CreateCompatibleBitmap( &dc, rcClient.Width(), rcClient.Height() );
tempDC.SelectObject( &m_bmp ); //(assume the m_bmp is a initial CBitmap ojbect)
memDC.SelectOjbect( &memBmp ); //First
memDC.BitBlt( p1,p2,..., &tempDc,...., SRCCOPY ); //Second
dc.BitBlt( p1,p2,......, &memDC,....., SRCCOPY ); //Third
//code end
I know how to use these codes but i don't why it does.
1.From codes i marked "First" and "Senond",I wonder if SelectObject( &memBmp ) only gives memDC's data member a value and BitBlt gives memDC something to display? if this why to use SelectObject()?
2.Codes marked "second" and "third". From "second" codes it use &tempDC as its parameter, but tempDC just only used SelectObject( &m_bmp ),i means it doesn't use BitBlt to disply somethig ,why it can be "BitBlt"
to memDC?
From "third" codes,dc's BitBlt use memDC as its parameter,and it executed BitBlt before.So I think this code is correct( but i know all these is correct haha...).
So i wonder,does the process "BitBlt" copys the SrcDC's disply things to DestDC,or copys the SrcDC's Bitmap object(been valued in SelectObject() )to DestDc to display?
My mother language is not English,and my english level is very lower(Sorry).I don't know if someone can understand my means.
I hope all of you gives me some advice,thank you!
this is the first time i asked question in this haha...
|
|
|
|
|
DC is a reference to the screen. CreateCompatibleDC() creates an area in memory that is the same as your screen (by 'same' i mean: if you use 16M colors each pixel on screen is 24 bits = 3 bytes, CreateCompatibleDC() will make the area in memory the same pixelsize) Notice CreateCompatibleDC() has no width and height parameter, so your compatible DC is initially 1 by 1 pixel big (!). CreateCompatibleBitmap() creates an area in memory that has the same pixelsize as the original bitmap. SelectObject() is needed to make the compatible DC the same size as the bitmap. Bitblt() copies one area of memory to another, where the screen itself is also an area of memory.
In your code you have:
1 DC
2 compatible DC's (tempDC and MemDC)
1 bitmap (m_bmp)
1 compatible bitmap (membmp)
Hope with this you can figure out our code
Rozis
|
|
|
|
|
thank you!I think i understand the compatible bitmap and compatible Dc more than before.
|
|
|
|
|
My Setup Module creates a New Proprietary Database Folder, populated with New or Default Entries. The location is by default: "C:Program Files\ MyCompany\Data" I do not place the folder in "...MyDocuments", because the individual files do not make sense on their own, and should only be accessed and modified by the bespoke software I wrote. Has anyone any code snippet which will force this new folder to be shared by all network users, and full Security Access by All Users. (i.e. Remove ALL this unwanted Protection)
Regards,
Bram van Kampen
|
|
|
|
|
|
transoft wrote: I want the class B' funct() to be called. But it did not get called.
Aside from syntax errors (see #5 here), your code does exactly what you want. Why are you saying that B::funt() is not being called?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
|
It appears that "standard" CTreeView message TVN_SELCHANGED is send twice - on mouse button down and mouse button up. In my initial case on key down I can retrieve the root node text and then on key up I get the selected node text.
Do I have to keep track of previous and current node myself or is there another way to get just the current selected node (text) ?
I tried to use TVN_SELCHANGING but despite the MSDN description of this message the LPTSTR pszText item in NMTREEVIEW structure contains garbage and not the text info about the node.
Thanks for reading. Any constructive help as always is appreciated.
|
|
|
|
|
Try this,
NMTREEVIEW* pnmtv = (NMTREEVIEW*) pNMHDR;
CTreeCtrl& tc = GetTreeCtrl();
HTREEITEM item = pnmtv->itemNew.hItem;
CString Tree_str=tc.GetItemText(item);
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
|
|
|
|
|
What you have suggested is just another way to get the node string.
The message is still posted twice and I get the old (or root if it is a first change) and then the new selected one. I guess I will set flag or static counter to ignore the first one (I don't need it)
Kind of gross!
Thanks for you help.
Cheers Vaclav
This explains why the new selection gets highlited on mouse button down and the old selection gets a funky rectangle around it! I just did not see that while stepping thru the code!
modified on Saturday, August 8, 2009 6:26 PM
|
|
|
|
|
1. what is stack.
2.how we use the graphics in c.
|
|
|
|
|
kumarashoka wrote: 1. what is stack.
Do you mean "what is A stack", or "what is THE stack"?
Oh well I'll just answer both, since they have a lot to do with each other.
A stack is a data structure that lets you put something on top, and the only thing you can remove from it is the top.
THE stack, is a stack (well partly..), which grows downwards in memory on every architecture that you are likely to care about (which doesn't usually matter, unless you want to do low level things), and it stores things like the address where the current function will return to if you say "return ", it is also used to store some local variables (explaining exactly which is a little hard, but if you pretend a variable is on the stack, the compiler will make sure it is), and sometimes it is used to store function parameters (but not always, equally complicated, and they will be on the stack if you want then to be), and there can be some other things there which you usually don't have to worry about.
For return addresses, THE stack really is a stack, but the variables and parameters are accessed as if the stack is just a piece of memory - and that's exactly what it is, but we like to pretend that we can only take things off the top to make it easier to manage (and also it wouldn't make much sense to Not treat it like that in the context of functions calls)
|
|
|
|
|
|
kumarashoka wrote: 1. what is stack.
A LIFO queue.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
|
how a pointer save memory and what is the limitation of pointer.
|
|
|
|
|
(overly simplified)
A pointer does not save memory; it only points to another place in memory that contains "the stuff you want to point to" outside of the stack space.
There is no limitation of using pointers, it is powerful, but somewhat more "dangerous" to use. (lost pointers, lost memory, unchecked dereferences... )
...
This signature was proudly tested on animals.
|
|
|
|
|
Maximilien wrote: outside of the stack space
What makes you say that? It doesn't really make it any simpler.. and it's not even true
|
|
|
|
|
I have copied one of my programs into another program and made the necessary changes for the new program. But whenever I open a AfxMessageBox(,); it displayes the previous program's title in the title portion of the message box. How do I remedy this?
Sample code:
CString str = "Select the [OK] button to begin processing the data";
int nTest = 0;
nTest = AfxMessageBox(str, MB_OK);
(The title of the messagebox is that of the previous program.)
A C++ programming language novice, but striving to learn
|
|
|
|
|
Is this a CWinApp based application? If so...what is the value of the string in your project with resource ID AFX_IDS_APP_TITLE?
CWinApp::m_pszAppName[^]
Best Wishes,
-David Delaune
|
|
|
|