Beginner: Is HWND unique?

Hi!
When I start an application twice and ask each application
for the handle of its main window (calling an inbuild COM
function), are the returned dwords guaranteed to be
different?

Thanks a lot for your help!
Volker
-- 
For email replies, please substitute the obvious.
0
9/1/2006 2:34:57 PM
vc.mfc 33608 articles. 0 followers. Follow

14 Replies
1414 Views

Similar Articles

[PageSpeed] 11

It is not guaranteed to be the same or different. You might get the same
HWND towice in a row, or might get different ones between two instances of
your program.

AliR.

"Volker Hetzer" <firstname.lastname@ieee.org> wrote in message
news:ed9gei$di9$1@nntp.fujitsu-siemens.com...
> Hi!
> When I start an application twice and ask each application
> for the handle of its main window (calling an inbuild COM
> function), are the returned dwords guaranteed to be
> different?
>
> Thanks a lot for your help!
> Volker
> -- 
> For email replies, please substitute the obvious.


0
AliR3470 (3235)
9/1/2006 3:01:36 PM
Volker Hetzer wrote:
> Hi!
> When I start an application twice and ask each application
> for the handle of its main window (calling an inbuild COM
> function), are the returned dwords guaranteed to be
> different?
> 
> Thanks a lot for your help!
> Volker

Yes.

-- 
Scott McPhillips [VC++ MVP]

0
Scott
9/1/2006 3:22:30 PM
I think, as Ali pointed out, that there is nothing unique about.  I often 
get the same number back when running a program multiple times and I will 
sometimes get a different value.  I think it just uses the "next" number 
available.  The handle is unique at the time it is used.

Tom

"Volker Hetzer" <firstname.lastname@ieee.org> wrote in message 
news:ed9gei$di9$1@nntp.fujitsu-siemens.com...
> Hi!
> When I start an application twice and ask each application
> for the handle of its main window (calling an inbuild COM
> function), are the returned dwords guaranteed to be
> different?
>
> Thanks a lot for your help!
> Volker
> -- 
> For email replies, please substitute the obvious. 


0
tserface (3860)
9/1/2006 3:22:42 PM
AliR wrote:

> It is not guaranteed to be the same or different. You might get the same
> HWND towice in a row, or might get different ones between two instances of
> your program.
> 
> AliR.
> 

Alir:

I think he means two instances running at the same time. In that case 
the HWND's must be different.

David Wilkinson
0
no-reply8010 (1791)
9/1/2006 3:37:47 PM
Thanks David, I thought he ment closing the app and startring again. But I
figured I cover all the bases anyway (no guarantee of anything)

AliR.

"David Wilkinson" <no-reply@effisols.com> wrote in message
news:ufX7NydzGHA.3656@TK2MSFTNGP04.phx.gbl...
> AliR wrote:
>
> > It is not guaranteed to be the same or different. You might get the same
> > HWND towice in a row, or might get different ones between two instances
of
> > your program.
> >
> > AliR.
> >
>
> Alir:
>
> I think he means two instances running at the same time. In that case
> the HWND's must be different.
>
> David Wilkinson


0
AliR3470 (3235)
9/1/2006 4:00:18 PM
If it is true that they are running at the same time they are absolutely 
unique according to the documentation.  I read it as though the OP was 
asking about subsequent running of the same program, but ...

Tom

"David Wilkinson" <no-reply@effisols.com> wrote in message 
news:ufX7NydzGHA.3656@TK2MSFTNGP04.phx.gbl...

> I think he means two instances running at the same time. In that case the 
> HWND's must be different.
>
> David Wilkinson 


0
tserface (3860)
9/1/2006 4:27:53 PM
It always amazes me how there can be so many right answer to the same 
questions changed only by the understanding of the axioms of the question. 
This is so much fun :o)

Tom

"AliR" <AliR@online.nospam> wrote in message 
news:44f8596e$0$15202$a8266bb1@reader.corenews.com...
> Thanks David, I thought he ment closing the app and startring again. But I
> figured I cover all the bases anyway (no guarantee of anything)
>
> AliR.


0
tserface (3860)
9/1/2006 4:28:56 PM
First, you have a very serious delusional system here.  You have referred to HWNDs as
DWORDs.  They are not.  They are HWNDs, which is a data type used to represent window
handles.  Note that in Win64, an HWND is definitely *not* a DWORD, and storing an HWND in
a DWORD will result in truncation of 32 bits of critical information.  Never pretend that
HWNDs are DWORDs are interchangeable.  Never pretend that *any* data type is some other
data type unless you are absolutely dead certain you know what you're doing.  In the case
of *any* HANDLE, and *any* pointer, there is absolutely no guarantee that they are
compatible with int, LONG, DWORD, etc; you may safely assume that they will never be.

If you need an integer value that can hold a pointer or handle, you can use UINT_PTR,
INT_PTR, LONG_PTR or DWORD_PTR, for example.  

The numeric value of a window handle is unique, system-wide.
					joe

On Fri, 01 Sep 2006 16:34:57 +0200, Volker Hetzer <firstname.lastname@ieee.org> wrote:

>Hi!
>When I start an application twice and ask each application
>for the handle of its main window (calling an inbuild COM
>function), are the returned dwords guaranteed to be
>different?
>
>Thanks a lot for your help!
>Volker
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15972)
9/1/2006 5:10:41 PM
At any given instant in time, all window handles representing all currently-existing
windows are unique.  The system is free to recycle them any time it feels like doing so,
once the window associated with the handle has been destroyed.
				joe

On Fri, 1 Sep 2006 08:22:42 -0700, "Tom Serface" <tserface@msn.com> wrote:

>I think, as Ali pointed out, that there is nothing unique about.  I often 
>get the same number back when running a program multiple times and I will 
>sometimes get a different value.  I think it just uses the "next" number 
>available.  The handle is unique at the time it is used.
>
>Tom
>
>"Volker Hetzer" <firstname.lastname@ieee.org> wrote in message 
>news:ed9gei$di9$1@nntp.fujitsu-siemens.com...
>> Hi!
>> When I start an application twice and ask each application
>> for the handle of its main window (calling an inbuild COM
>> function), are the returned dwords guaranteed to be
>> different?
>>
>> Thanks a lot for your help!
>> Volker
>> -- 
>> For email replies, please substitute the obvious. 
>
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
0
newcomer (15972)
9/1/2006 5:12:24 PM
Yeah, I think hope that's what we said, even though we were a bit confused 
by the question at first.

Tom

"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message 
news:udqgf2hi2pkt5c4p66gq26idp4krmu9ql2@4ax.com...
> At any given instant in time, all window handles representing all 
> currently-existing
> windows are unique.  The system is free to recycle them any time it feels 
> like doing so,
> once the window associated with the handle has been destroyed.
> joe


0
tserface (3860)
9/1/2006 5:46:15 PM
"Tom Serface" <tserface@msn.com> wrote in message 
news:%23KQ35OezGHA.996@TK2MSFTNGP03.phx.gbl...
> It always amazes me how there can be so many right answer to the same 
> questions changed only by the understanding of the axioms of the question. 
> This is so much fun :o)

Masochist!  ;)

-Pete 


0
9/1/2006 6:00:25 PM
Window handles are unique, but they get reused after a window dies. If 
window handles weren't unique, the whole windows system would have been in 
chaos and we would not have programmed anything as is done today.

-- 
Vipin Aravind
http://www.explorewindows.com/Blogs


"Volker Hetzer" <firstname.lastname@ieee.org> wrote in message 
news:ed9gei$di9$1@nntp.fujitsu-siemens.com...
> Hi!
> When I start an application twice and ask each application
> for the handle of its main window (calling an inbuild COM
> function), are the returned dwords guaranteed to be
> different?
>
> Thanks a lot for your help!
> Volker
> -- 
> For email replies, please substitute the obvious. 


0
vipin (697)
9/2/2006 7:51:21 PM
Vipin schrieb:
> Window handles are unique, but they get reused after a window dies. If 
> window handles weren't unique, the whole windows system would have been in 
> chaos and we would not have programmed anything as is done today.
Ok, thanks a lot for all the answers!
To clean up the confusion, yes, I meant two applications (like two excel
instances) running at the same time on the same PC.

I wasn't sure because I am just starting windows programming at that level
and theoretically it would have been possible to number them for each
process separately, like file handles on unix. So I wasn't sure.

Lots of Greetings!
Volker
-- 
For email replies, please substitute the obvious.
0
9/4/2006 9:52:36 AM
Tom Serface schrieb:
> If it is true that they are running at the same time they are absolutely 
> unique according to the documentation.
Is there any chance to provide me with a link that I can show to my boss?
I didn't find anything at the online documentation, like for instance
http://windowssdk.msdn.microsoft.com/en-us/library/ms632679.aspx.

 > I read it as though the OP was
 > asking about subsequent running of the same program, but ...
No, I want to select between n programs running concurrently.
Sorry for the misunderstanding.

Lots of Greetings!
Volker
-- 
For email replies, please substitute the obvious.
0
9/4/2006 11:13:55 AM
Reply:

Similar Artilces:

Is there help for beginners?
I just bought this wonderful computer from Dell, and Microsoft Outlook came with it. I cannot figure out how to use it! I can get email, but I cannot send it! It stays in the Outbox forever, and when I try to send it from there, I'm told it's not possible. Aren't there any beginner tutorials I can look at? I really could use some help! Thanks! -- drexlori In news:A1E6C03C-FCA4-4125-B97A-B4515798D670@microsoft.com, drexlori <drexlori@discussions.microsoft.com> typed: > I just bought this wonderful computer from Dell, and Microsoft > Outlook came with it. I cannot...

Finding Unique Data
I have 3 coumns in a table. all 3 columns have duplicate data. But I want to find unique data in column A only. How do i do this in ACESS 2007 ? Please help. hi Rumy, On 02.02.2010 15:40, Rumy wrote: > I have 3 coumns in a table. all 3 columns have duplicate data. But I want to > find unique data in column A only. How do i do this in ACESS 2007 ? Please > help. Maybe so: SELECT * FROM yourTable WHERE (A <> B) AND (A <> C) mfG --> stefan <-- Under query types, you have one for Find Umatched Data. That will tell you which data is unique. --...

get instance of ie 7 from hwnd
Hi i am using visual sudio 2005 in windows server 2008 and Internet explorer 8 but using Emulate IE7 and porgramming with visual c++/MFC I already have the hWnd of the ie and when i use SetWindowPos with the hWnd the ie window does change but i need to get The IHTMLDocument or IWebBrowser2 form that hWnd i read kb 176792 "How to get IHTMLDocument2 from a HWND" and kb 176792 "How to connect to a running instance of Internet Explorer" and tried them but they didnt work for me if anyones knows what might be the problem please tell me thanks Well, I am using same code and it w...

Help for a Beginner Among Beginners
Hello, would anyone kindly point me in the general direction of a solution to a very basic database question (I'm not even sure where to ask)? I have a small consulting company of a dozen employees, with no IT dept. We have info from approx 1000 clients stored in an Access 2000 database which is 10MB in size. A former employee made a simple form, which we populate with client info, and we just add records. The file is on a file server, and all 12 of us access it simultaneously. Recently, I hired a guy to setup a VPN, so that employees can add data to the database while on the road. Howeve...

Earn $200 per day without a website
Tired of wasting your time & hard earned money on "intelligent" programs which promise to make you rich overnight? Then read on, because I am going to show you............. How I made over $2000 in just 10 days using a ridiculously stupid technique I stole from my own affiliate Click the following link to see the entire procedure explained step-by- step. http://www.showroute.com/odp I Got MY Own ATM. J http://www.showroute.com/odp Wilson. ...

Excel 2003-Beginner
I'm using Excel 2003. Sorry, I'm if not explaining this well. I'm trying to put information in a column that comes from another worksheet in the same book but it depends on what is entered in 2 other columns in the first worksheet. I'll try to give complete info: Let's say Column A asks you to pick 1 of 5 gems: Agate, Turquoise, Garnet, Diamond, Pearl Let's say Column B asks you to pick 1 of 6 Countries: US, Can, UK, China, Japan, Germany The other worksheet has a table with data (its a number in each cell) representing all the possible permutatio...

Formula for unique records
I am trying to make a report a little more user friendly for a novice excel user, and I am trying to use all formula's instead of pivotables on large data sources. Is there a formula that will pull unique records out of a list of customer #'s as an example without having to use auto filter which would then require more manual intervention. I am then using sumproducts using the customer number to create the report. >I am trying to use all formula's instead of pivotables >on large data sources. How large is large? More than a few hundred rows? Formulas to e...

counting unique entries in a list
Hey Guys! I was wondering if someone could help me. I am trying to write a script that goes parses through an excel file that contain iventory information. I already wrote code to cover most of the functionality I am trying to do, but I am having some difficulty with respect to two areas. 1) The lists vary in length so some 10 records others have 500 records. Is there an easy way to do a loop to the last element in the list? Like... for n=1 to sheet.end or something like that? (I do not want to manually change the bounds for each list.) 2) I am also finding it difficult to automatical...

Beginner Here!
Hello, I'm looking for decent internet resources to learn how to use Great Plains software. I'm a VB developer starting a new job with a company that uses GP, but I've never used it. Any information would be greatly appreciated. Thanks, Jason Jason, Your best bet is to read through the manuals that come on the Great Plains cd. Then log into the sample company and try each transaction type, report option etc. It's just sample data so you can't hurt anything. This hands on approach is the best way to learn the system. We provide personlized one on one training via r...

XPath beginners question
I have limited experience of XML and I am trying to use XPath to get at all <tag4> elements given a certain value for <tag3> (see my example below : <?xml version="1.0" encoding="ISO-8859-1"?> <tag1> <tag2> <tag3> <tag4> <tag4> <tag4> </tag2> <tag2> <tag3> <tag4> <tag4> </tag2> </tag1> Any assistance would be really appreciated. Cheers, Mike *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENE...

Unique Attachment problem
Problem: Cannot receive attachments in Outlook 2002 (Win XP)from one specific party. Read online FAQ's and nothing seems to appy to this particular problem. I get attachments fine from everyone else, including similar types (filename extensions) that I can't get from "Peter". Peter is able to successfully send email attachments to everyone but me. He uses Windows 2000 and EDORA for his email. Outlook never "warns" me I've received an "unsafe" file. Download time is equivalent to time it would have taken to receive attachment but it is not i...

Unique Number #2
I am creating an Invoice template in which I need it to generate a unique random number each time the spreadsheet is opened. Anyone have any ideas that I could try? Thanks Tom ...

Beginners question
I do not understand the following. Please try it and you will see what I mean. I create a brand new project starting on Mon 31/11/2009. I do not change any default settings. I create a task called "Project" and create 2 subtasks both with a duration of 5 days and link them. Why does the second task start on Fri 04/12/2009? And not on the Mon 07/12/2009? Task 1 starts on Mon and finishes on Fri. But Task 2 starts on Fri and finishes on Fri. ???..... I really don't understand how this can be right --- or helpful! If I create a further 2 tasks, again with 5 d...

(beginner) getch
Hello i have a problem in VC++ i cant detect the alt key when pressed with the function getch.... please i want a function which get a flag when a alt+a key pressed for example (in C++) I have windows 2000 "kanaan" <kanaan81@hotmail> wrote in message news:0f4101c36d73$1137c4c0$a301280a@phx.gbl... > Hello > > i have a problem in VC++ i cant detect the alt key when > pressed with the function getch.... > > please i want a function which get a flag when a alt+a key > pressed for example (in C++) > > I have windows 2000 ooooo, getch... haven'...

Beginner: Adding additional domains
Hi EveryOne, I have a small network (actually a test network at home) where I have installed Windows 2003 Server Standard Edition (Evaluation version) and Exchange 2003... I have configured my domain abc.local... I installed Exchange without any problems... Everything is working fine... except that I couldn't find how to configure Exchange to accept my domains abc.net and abc.com... Searching on google (How to add a second domain to Exchange) didn't provide me a lot of help. Thanks in advance for your help! Regards, BY You should add additional domains in the recipient po...

find rows for unique data in 1 column and different data in other.
I have a spreadsheet that contains 1 column that contains cells that may contain the same information such as A2 and A4 and A6 all contain 4144638872 - in columns B-P there may be information that may be different for each 1234 cell: A2=4144638872 B2=278954 A4=4144638872 B4=195871 A6=4144638872 B6=238521 I want to return a result of unique rows based on only 1 phone # that exists in column A. I need the information in column B and other columns and I don't care which of the 3 remain in the result sheet. Basically I have a list of file#s with the same phone #s and I only want ...

select only companies having more than one unique zip code?
In the following list I have 4 different companies -- 'abc', 'bcd', 'cde', and 'def' 'abc' is listed 4 times and contains 2 different zipcodes, 'bcd' is listed twice but only contains one unique zip code, 'cde' contains 3 different zip codes, and 'def' is listed only once with one zip code. I need to select companies 'abc' and 'cde' because they contain more than one unique zip code. What is the tsql to accomplish this kind of query? create table #tmpA(rowID int Identity(1,1), Co varchar(50), zip ...

A Couple of Beginner Questions
1. Where can I learn how to write Macros? 2. I know how to create new "tabs" in Excel. Can I create a "tab" that is a subtab? For instance, if my workbook consists of a "tab"(spreadsheet) named "Colors" and another spreadsheet named "Shapes", how do I create subcategories of the spreadsheet "Colors" and name them Black, Blue, Yellow etc.? "Shapes" and "Colors" are two spreadsheets that need to be subdivided into smaller spreadsheets. 3. I need to remove a group of checkboxes that are layered one on ...

Book for a windows/c++/mfc beginner...
Hi, I have previous coding experience, but not in the windows environment and not in C/C++. I have just got a copy of MS Visual C++ Express and want to learn how to code C++ for Windows. As I understand it I need to use MFC for the windows stuff, and without it Visual C++ would just be command prompt based? Is that correct? If so then I need a book that teaches me MFC and C++, preferably in the Visual C++ environment... Which is the best book/books for this? Thanks. anon418600J5 wrote: > Hi, > > I have previous coding experience, but not in the windows environment and...

beginners
I've never used excel before. Are the courses list in the order in which I should learn? If not which one should I start with? Con9 Which courses list are you referring to? Some basic Excel tutorials on-line. http://www.usd.edu/trio/tut/excel/index.html http://www.baycongroup.com/el0.htm Microsoft Training Courses. http://office.microsoft.com/en-us/training/CR061831141033.aspx Gord Dibben Excel MVP On Thu, 4 Nov 2004 12:48:05 -0800, "Con9" <Con9@discussions.microsoft.com> wrote: >I've never used excel before. Are the courses list in the order in which I &...

Beginner Tutorial
Hi, Find a beginner tutorial on MFC on my website. -- Vipin Aravind http://www.explorewindows.com ...

Count of Unique numbers in a column
Hi, I have some no's in a column,in which some are duplicating & some are unique no's.Like 825 921 941 921 822 825 941 421 Now i want to count the unique no's in a column. The result should be 5 for the above example. Note : can the result be taken out in a cell instead of using an another column. ------------------------------------------------ ~~ Message posted from http://www.ExcelTip.com/ ~~View and post usenet messages directly from http://www.ExcelForum.com/ Enter the array formula: =SUM(IF(LEN(A1:A100),1/COUNTIF(A1:A100,A1:A100))) to exclude 0 values, or as: =SU...

How do I create a unique unbound DataGridViewColumn?
I need a tutorial on how to create an unbound column for a datagridview. everything is unbound and programmatically populated. is CellValidating the appropriate place to enforce non-duplication? how to enforce it? -- Wannabe Geek "wannabe geek" wrote: > I need a tutorial on how to create an unbound column for a datagridview. > everything is unbound and programmatically populated. > is CellValidating the appropriate place to enforce non-duplication? how to > enforce it? > -- > Wannabe Geek Oh, now I see i will need numerous columns combined in...

HWND for the Main Window in MFC
This is a multi-part message in MIME format. ------=_NextPart_000_0028_01C3BDC0.CD4AAEA0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I'm creating a class in a header file for my MFC apps. I need to place a = messagebox in the class to display errors. The messagebox must be = attached to the main window in my dialog-based MFC app. However, the = MessageBox() function requires an HWND parameter to do this. The problem is that I don't know the HWND that would be associated with = the main dialog. I've searched though several...

Beginner to GUI
HI, a quick question, I am a fairly experienced C++ and Java programmer (console, swing and DirectX). But I have no experience using VC++ to build a GUI. I have created an MFC project, but do not know what to do next. I can see how to create dialogs an d maybe show them, but how do I add something to the main frame?? I am trying to create a tabbed user interface. On each tab "pane" I want a series of components. How to I go about createing this tabbed pane on the "main frame". In Jbuilder (yes I know its Java+ Swing NOT C++ + MFC), I just selected the main frame in...