mIRC Homepage
Posted By: da_hype DLL HELP!! - 16/05/04 12:44 AM
i did not get far with this DLL... was wondering if anyone could help me, with maybe 1 of the functions and i'll try and figure the rest out..

was looking at this page... but don't get how to use it..
http://msdn.microsoft.com/library/defaul...sktopwindow.asp

Code:
;
;Start's here...
;
#pragma check_stack(off)
#pragma comment(linker,"/OPT:NOWIN98")
#include <windows.h>

// general constants
#define mFunc(x) int __stdcall x(HWND mWnd, HWND aWnd, char *data, char *parms, BOOL show, BOOL nopause)

// Structures
typedef struct {
DWORD mVersion;
HWND mHwnd;
BOOL mKeep;
} LOADINFO;
HWND mHWnd;

mFunc(Desktop)
{
//Sticks any window onto the desktop 
}

mFunc(UnDesktop)
{
//Put's desktop window back into mIRC 
}

mFunc(IsDesktop)
{
//Checks to see if a window is on the desktop
}
Posted By: Narusegawa_Naru Re: DLL HELP!! - 16/05/04 10:49 AM
really theres no need for mfc in this case.
the functions your looking for a re SetParent and GetParent.

To make a window a desktop window you have to do 2 things.

first use SetParent using GetDesktopWindow() as the hParent and second use SetWindowLong to remove the WS_CHILD style bit. this is not done for you. something like this would work

SetParent(hWnd,GetDesktopWindow());
SetWindowLong(hWnd,GWL_STYLE,GetWindowLong(hWnd,GWL_STYLE) &~WS_CHILD);

to reverse that simply re add the WS_CHILD and set the parent back to hte previous value.

You can use if (GetParent(hWnd) == GetDesktopWindow()) to tell if its on the desktop

Have Fun smile
Posted By: da_hype Re: DLL HELP!! - 16/05/04 12:19 PM
[code]
mFunc(Desktop)
{
//get the hwnd from mirc with something like
// $dll(my.dll,Desktop,$window($active).hwnd)
HWND mircwindow = (HWND)atoi(data);
//get the desktop hwnd
HWND dpt = GetDesktopWindow();
SetParent(mircwindow,dpt);
lstrcpy(data,"yay");
return 3;
}
[code]

and this would work for
//dll bla.dll Desktop $window(#scripting).hwnd

is this right?




Posted By: Narusegawa_Naru Re: DLL HELP!! - 16/05/04 08:31 PM
dont forget to remove the WS_CHILD style bit.
Posted By: da_hype Re: DLL HELP!! - 17/05/04 02:40 AM
"dont forget to remove the WS_CHILD style bit. " << i don't get you.. frown what do i change in the code bellow?



Code:
mFunc(Desktop)
{
//get the hwnd from mirc with something like
// $dll(my.dll,Desktop,$window($active).hwnd)
HWND mircwindow = (HWND)atoi(data);
//get the desktop hwnd
HWND dpt = GetDesktopWindow();
SetParent(mircwindow,dpt);
lstrcpy(data,"yay");
return 3;
}
Posted By: starbucks_mafia Re: DLL HELP!! - 17/05/04 10:03 AM
Well Naru gave you two lines of example code:
SetParent(hWnd,GetDesktopWindow());
SetWindowLong(hWnd,GWL_STYLE,GetWindowLong(hWnd,GWL_STYLE) &~WS_CHILD);


And you're currently using one of them here:
SetParent(mircwindow,dpt);

So I don't think it takes too much imagination to guess that the other line is what you need:
SetWindowLong(mircwindow,GWL_STYLE,GetWindowLong(mircwindow,GWL_STYLE) &~WS_CHILD);

Then when you're setting the window as a child of mIRC again that line would (presumably) be:
SetWindowLong(mircwindow,GWL_STYLE,GetWindowLong(mircwindow,GWL_STYLE) &WS_CHILD);
Notice the missing bitwise NOT operator (~).
Posted By: Narusegawa_Naru Re: DLL HELP!! - 17/05/04 11:08 AM
close you would use | WS_CHILD to readd it.
Posted By: da_hype Re: DLL HELP!! - 17/05/04 01:17 PM
OK this is what i vae now... the desktop works fine.. but can't test the undesktop and isdesktop for some reason.. When it adds the window to the desktop..ican't type anything on it. i can right click and move it around.. but can't type frown anyidea's why?

Code:
#pragma check_stack(off)
#pragma comment(linker,"/OPT:NOWIN98")
#include &lt;windows.h&gt;

// general constants
#define mFunc(x) int __stdcall x(HWND mWnd, HWND aWnd, char *data, char *parms, BOOL show, BOOL nopause)

mFunc(Desktop)
{
	//get the hwnd from mirc with something like
	//echo -s $dll(hdll.dll,Desktop,$window($active).hwnd)
	HWND mircwindow = (HWND)atoi(data);
	//get the desktop hwnd
	HWND dpt = GetDesktopWindow();
	SetParent(mircwindow,dpt);
	lstrcpy(data,"S_OK");
	return 3;
}


mFunc(UnDesktop)
{
//echo -s $dll(hdll.dll,UnDesktop,$window($active).hwnd)
	HWND mircwindow = (HWND)atoi(data);
	HWND dpt = GetDesktopWindow();
	SetWindowLong(mircwindow,GWL_STYLE,GetWindowLong(mircwindow,GWL_STYLE) |WS_CHILD);
	lstrcpy(data,"S_OK");
	return 3;
}


mFunc(IsDesktop)
{
	// $dll(hdll.dll,IsDesktop,$window($active).hwnd)
	HWND mircwindow = (HWND)atoi(data);
	HWND dpt = GetDesktopWindow();
	if (GetParent(mircwindow) == dpt) 
	lstrcpy(data,"S_OK");
	return 3;
}
Posted By: starbucks_mafia Re: DLL HELP!! - 17/05/04 03:31 PM
Oh yeah, that would make more sense wouldn't it. crazy
Posted By: da_hype Re: DLL HELP!! - 17/05/04 04:16 PM
"Oh yeah, that would make more sense wouldn't it. " <<< huh?

If it help's i'm using mirc 6.12 and windows XP... frown
Posted By: da_hype Re: DLL HELP!! - 18/05/04 04:03 PM
can anyone help me please? frown
Posted By: Narusegawa_Naru Re: DLL HELP!! - 18/05/04 09:47 PM
your Undesktop fn does not set the parent back to the original parent window.

as for the Isdesktop it probably would be better to test to see if the WS_CHILD style bit is currently set.

UINT style = (UINT)GetWindowLong(hwnd,GWL_STYLE);
if ((style & WS_CHILD) == WS_CHILD) //it is not a desktop window
else //it is
Posted By: Narusegawa_Naru Re: DLL HELP!! - 18/05/04 09:52 PM
also in your isdektop you fill data only when it is a desktop window but do nothing if it isnt. the best thing to do would be fill it with $true and $false. this way scripters can use it in direct comparisons for example

if ($dll(blah blah)) //its a desktop window

or

if (!$dll(blah blah)) //its not a desktop window

of course the convention you use is up to you. your current setup however will always return a true value. if its not a desktop window it will return whatever data was (i.e the window handle) so they cant use the ! negate operator. again its up to you it just seems to make more sense and fits easier with mIRC script.

oops meant to edit the previous post sorry
© mIRC Discussion Forums