C/C++ Windows API

Moderators: Lundin
Number of threads: 443
Number of posts: 1215

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
minimize other window Posted by joliouscezar on 15 Aug 2010 at 6:04 AM

i work on project with wni 32 API in VC++6.0.
i have function that take an argument whose this is a HWND variable.
i want minimize window that have this handle.
this is source of my function

void min2(HWND hwnd){
typedef struct POINT{
long x;
long y;
}point;


typedef struct RECT{
long int top;
long int bottom;
long int left;
long int right;
}rect;
typedef struct tagWINDOWPLACEMENT {
UINT length;
UINT flags;
UINT showCmd;
POINT ptMinPosition;
POINT ptMaxPosition;
RECT rcNormalPosition;
} mn;
tagWINDOWPLACEMENT *PWINDOWPLACEMENT, *PWT;
tagWINDOWPLACEMENT myWP;

myWP.length = sizeof(WINDOWPLACEMENT);
myWP.showCmd = SW_SHOWMINIMIZED;
myWP.flags = WPF_SETMINPOSITION;

myWP.ptMinPosition.x = (long)0;
myWP.ptMinPosition.y = (long)0;
myWP.rcNormalPosition.left = (long)10;
myWP.rcNormalPosition.top = (long)100;
myWP.rcNormalPosition.right = (long)100;
myWP.rcNormalPosition.bottom = (long)100;



PWT = &myWP;

if (IsWindow(hwnd))
::SetWindowPlacement(hwnd ,*PWT);


return;
}

VC take an error in compiling that i do not understand it?
i do all work that i can do but .....

e:\myspy\winspy.cpp(402) : error C2664: 'SetWindowPlacement' : cannot convert parameter 2 from 'struct min2::tagWINDOWPLACEMENT' to 'const struct tagWINDOWPLACEMENT *'
No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
Error executing cl.exe.

very thanks for any reply


Report
Re: minimize other window Posted by AsmGuru62 on 19 Aug 2010 at 5:09 AM
Why do you need all these "typedef struct ..."?
These are all defined in WINDOWS.H.

To pass an address of structure to a function - simply pass "&myMN" or whatever. No need to put it into some variable. You have passed "*ptr" and that means pass whole structure and not the pointer. That is the cause of compiler error.

This function will work without need of any structures:
http://msdn.microsoft.com/en-us/library/ms633548(VS.85).aspx



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.