<commit_before>/*
	* Various docking commands that are not part of the old UltraDock
	*
	*	TODO: Add subclassing of channel/custom/toolbar/switchbar/treelist? SetClassLongPtr(new_wndproc) & FindWindowEx(classname)
*/

#include "../../defines.h"

extern mIRCDLL mIRCLink;

typedef struct tagDCXDOCK {
	WNDPROC oldProc;
	HWND win;
} DCXDOCK, *LPDCXDOCK;

BOOL CALLBACK EnumDocked(HWND hwnd,LPARAM lParam)
{
	LPDCXDOCK dd = (LPDCXDOCK)GetProp(hwnd,"dcx_dock");
	if (dd != NULL) {
		RemoveProp(hwnd,"dcx_dock");
		SetWindowLong(hwnd, GWL_WNDPROC, (LONG)dd->oldProc);
		delete dd;
	}
	return TRUE;
}

LRESULT CALLBACK mIRCDockWinProc(HWND mHwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	LPDCXDOCK dd = (LPDCXDOCK)GetProp(mHwnd,"dcx_dock");
	if (dd == NULL)
		return DefWindowProc(mHwnd,uMsg, wParam, lParam);
	switch (uMsg) {
    case WM_SIZE:
      {
				wsprintf(mIRCLink.m_pData, "/.signal DCX size %d %d %d", dd->win, LOWORD(lParam), HIWORD(lParam));
				SendMessage(mIRCLink.m_mIRCHWND, WM_USER +200, 0, mIRCLink.m_map_cnt);
      }
      break;
		case WM_DESTROY:
			{
				RemoveProp(mHwnd,"dcx_dock");
				SetWindowLong(mHwnd, GWL_WNDPROC, (LONG)dd->oldProc);
				delete dd;
				PostMessage(mHwnd, uMsg, 0, 0);
				return 0L;
			}
			break;
	}
	return CallWindowProc(dd->oldProc,mHwnd,uMsg,wParam,lParam);
}
void DockWindow(HWND mWnd,char *data,HWND temp,char *find)
{
	RECT rc;
	HWND sWnd;

	// if HWND exists
	if (IsWindow(temp)) {
		// get window HWND
		if (find == NULL) sWnd = GetDlgItem(mWnd,32918);
		else sWnd = FindWindowEx(mWnd,NULL,find,NULL);
		if (IsWindow(sWnd)) {
			// change win style to child
			//RemStyles(temp,GWL_STYLE,WS_CAPTION | DS_FIXEDSYS | DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_OVERLAPPED);
			RemStyles(temp,GWL_STYLE,WS_POPUP);
			AddStyles(temp,GWL_STYLE,WS_CHILDWINDOW);

			// get window pos
			GetWindowRect(temp,&rc);

			if (GetProp(sWnd,"dcx_dock") == NULL)
			{ // if prop not alrdy set then set it & subclass.
				// subclass window.
				LPDCXDOCK dd = new DCXDOCK;
				if (SetProp(sWnd,"dcx_dock",dd))
				{
					dd->oldProc = (WNDPROC)SetWindowLong(sWnd,GWL_WNDPROC, (LONG)mIRCDockWinProc);
					dd->win = mWnd;
				}
				else {
					delete dd;
					lstrcpy(data,"-ERR Unable to SetProp");
					return;
				}
			}
			// set parent and move it to top-left corner<commit_msg>changed the dcx size signal to return the window type as well for all windows not just main mIRC window.<commit_after>/*
	* Various docking commands that are not part of the old UltraDock
	*
	*	TODO: Add subclassing of channel/custom/toolbar/switchbar/treelist? SetClassLongPtr(new_wndproc) & FindWindowEx(classname)
*/

#include "../../defines.h"

extern mIRCDLL mIRCLink;

typedef struct tagDCXDOCK {
	WNDPROC oldProc;
	HWND win;
	TString type;
} DCXDOCK, *LPDCXDOCK;

BOOL CALLBACK EnumDocked(HWND hwnd,LPARAM lParam)
{
	LPDCXDOCK dd = (LPDCXDOCK)GetProp(hwnd,"dcx_dock");
	if (dd != NULL) {
		RemoveProp(hwnd,"dcx_dock");
		SetWindowLong(hwnd, GWL_WNDPROC, (LONG)dd->oldProc);
		delete dd;
	}
	return TRUE;
}

LRESULT CALLBACK mIRCDockWinProc(HWND mHwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	LPDCXDOCK dd = (LPDCXDOCK)GetProp(mHwnd,"dcx_dock");
	if (dd == NULL)
		return DefWindowProc(mHwnd,uMsg, wParam, lParam);
	switch (uMsg) {
    case WM_SIZE:
      {
				if (dd->type.len())
					wsprintf(mIRCLink.m_pData, "/.signal DCX size %s %d %d %d", dd->type.to_chr(), dd->win, LOWORD(lParam), HIWORD(lParam));
				else
					wsprintf(mIRCLink.m_pData, "/.signal DCX size Custom %d %d %d", dd->win, LOWORD(lParam), HIWORD(lParam));
				SendMessage(mIRCLink.m_mIRCHWND, WM_USER +200, 0, mIRCLink.m_map_cnt);
      }
      break;
		case WM_DESTROY:
			{
				RemoveProp(mHwnd,"dcx_dock");
				SetWindowLong(mHwnd, GWL_WNDPROC, (LONG)dd->oldProc);
				delete dd;
				PostMessage(mHwnd, uMsg, 0, 0);
				return 0L;
			}
			break;
	}
	return CallWindowProc(dd->oldProc,mHwnd,uMsg,wParam,lParam);
}
void DockWindow(HWND mWnd,char *data,HWND temp,char *find)
{
	RECT rc;
	HWND sWnd;

	// if HWND exists
	if (IsWindow(temp)) {
		// get window HWND
		if (find == NULL) sWnd = GetDlgItem(mWnd,32918);
		else sWnd = FindWindowEx(mWnd,NULL,find,NULL);
		if (IsWindow(sWnd)) {
			// change win style to child
			//RemStyles(temp,GWL_STYLE,WS_CAPTION | DS_FIXEDSYS | DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_OVERLAPPED);
			RemStyles(temp,GWL_STYLE,WS_POPUP);
			AddStyles(temp,GWL_STYLE,WS_CHILDWINDOW);

			// get window pos
			GetWindowRect(temp,&rc);

			if (GetProp(sWnd,"dcx_dock") == NULL)
			{ // if prop not alrdy set then set it & subclass.
				// subclass window.
				LPDCXDOCK dd = new DCXDOCK;
				if (SetProp(sWnd,"dcx_dock",dd))
				{
					dd->oldProc = (WNDPROC)SetWindowLong(sWnd,GWL_WNDPROC, (LONG)mIRCDockWinProc);
					dd->win = mWnd;
					dd->type = find;
				}
				else {
					delete dd;
					lstrcpy(data,"-ERR Unable to SetProp");
					return;
				}
			}
			// set parent and move it to top-left corner
{'fraction_non_alphanumeric': 0.1325106210803156, 'fraction_numerical': 0.004855351001416144, 'mean_word_length': 3.832844574780059, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4875540', 'n_tokens_mistral': 2349, 'n_tokens_neox': 2064, 'n_words': 428}