Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / January 2005

Tip: Looking for answers? Try searching our database.

Win32 GetParent Method problem

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ezitech@yahoo.com - 04 Jan 2005 09:18 GMT
Hello,
I have a problem with using the Win32 method GetParent.
As I read in msdn, if this method is called on a handle which doesn't
have a parent (top level and unowned window) then the result is null,
the same for when the method fails.
They wrote that for distiguishing between failure, and a window
with no parent ,i have to use the GetLastError.
The problem is that when I call GetParent(handle) and the handle
doesn't have a parent, the GetLastError returns the same error which
was before calling the method GetParent, meaning the method didn't
change it all, so i can't know if the method failed or succeeded.As far
as know, the method should set the last error to SUCCESS so it can be
distiguishd.
Does someone know how i can distinguish between these two
situations??

Thanks
Mattias Sj?gren - 04 Jan 2005 12:05 GMT
In .NET you should use Marshal.GetLastWin32Error() rather than
GetLastError().

Mattias

Signature

Mattias Sjögren [MVP]  mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

ezitech@yahoo.com - 04 Jan 2005 12:57 GMT
I used Marshal.GetLastWin32Error()  and not GetLastError().
The same problem also exist with C++ code .
For example:
SetLastError(2);

int errorBeforeCall = GetLastError(); // =2

HWND parent = GetParent(hWnd);//parent = NULL because hWnd has no
parent

int errorAfterCall = GetLastError(); //=2 (The same as before!!)

And again, my question is how can I know if the hWnd has no parent or
if
the call failed??

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.