create an image on page with user32.dll

Aquí puedes preguntar o compartir tus dudas y conocimientos acerca del programa
Hi all
how can to create an image on ams pages with user32.dll ??
this is simple code that can draw a label on page :

LabelHandle = WinApi.CreateWindowEx(0, "STATIC", "this is label", WS_CHILD+WS_VISIBLE, 0, 0, 100, 20, ParentHandle, 0);

but i want to create image with user32.dll on my page
You have to endorse to the winapi drawing model, process message pump of desired window and draw the raw bitmap using bitblt method in the WM_PAINT callback.

Obviously you have to setup a destination window (a STATIC could do the trick), save its HDC, read the image and get raw BITMAP ptr from gdi32 methods etc...

this is a simple C drawing routine that you could easily port to reflection.

hBitmap = (HBITMAP)LoadImage(hInst, L"c:\\test.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
case WM_PAINT:
HDC hdc;
BITMAP bitmap;
HDC hdcMem;
HGDIOBJ oldBitmap;

hdc = BeginPaint(hWnd, &ps);

hdcMem = CreateCompatibleDC(hdc);
oldBitmap = SelectObject(hdcMem, hBitmap);

GetObject(hBitmap, sizeof(bitmap), &bitmap);
BitBlt(hdc, 0, 0, bitmap.bmWidth, bitmap.bmHeight, hdcMem, 0, 0, SRCCOPY);

SelectObject(hdcMem, oldBitmap);

EndPaint(hWnd, &ps);
you can do that by Ams Plugin Maker Easily
So thanks

actually i build an object plugin with ams plugin maker
now, i want when user clicked on properties button of object plugin, show a windows that contained object plugin info
so, i write below code in ams plugin maker :

###Object Functions###

function ShowProperties(ObjectPtr, PluginFolder)
	ActiveWindow = __Window.GetActiveWindow()
	DialogBoxOpen = __Plugin.ModalDialogBoxOpen(ActiveWindow, 300, 200, "CoolFX Object Plugin", "CallBack");

	if(DialogBoxOpen == IDOK) then
		return true;

		return false;

and for initialize and design Properties windows, i write below code :

###Object Functions###

function CallBack(hWnd, message, wParam, lParam)

	if (message == WM_INITDIALOG) then

		Parent = __Window.GetParent(hWnd);
		Font = __Window.SendMessage(Parent, WM_GETFONT, 0, 0);

		WindowEx = __Window.CreateWindowEx(0, "STATIC", "this is label", WS_CHILD+WS_VISIBLE, 10, 10, 280, 20, hWnd, 0);
		SendMessage = __Window.SendMessage(WindowEx, WM_SETFONT, Font, 0);

-- image type is .bmp or .png
-- image info to create with api here with this information       : x = 10, y = 40, width=280, height=100

		WindowEx = __Window.CreateWindowEx(0, "BUTTON", "OK", WS_CHILD+WS_VISIBLE+BS_PUSHBUTTON+BS_NOTIFY, 110, 165, 80, 25, hWnd, IDOK);
		SendMessage = __Window.SendMessage(WindowEx, WM_SETFONT, Font, 0);

		WindowEx = __Window.CreateWindowEx(0, "BUTTON", "Help", WS_CHILD+WS_VISIBLE+BS_PUSHBUTTON+BS_NOTIFY, 210, 165, 80, 25, hWnd, IDHELP);
		SendMessage = __Window.SendMessage(WindowEx, WM_SETFONT, Font, 0);

		return true;

	if(message == WM_CLOSE) then
		Close = __Plugin.ModalDialogBoxClose(hWnd, IDCANCEL);
		return true;

	if (message == WM_COMMAND) then
		local LoWord	= __Memory.LoWord(wParam);
		local HiWord	= __Memory.HiWord(wParam);
			if (HiWord == BN_CLICKED) then
				if (LoWord == IDOK) then
					Close = __Plugin.ModalDialogBoxClose(hWnd, IDOK);
					return true;

return false;

now, even though that i can create image with ams plugin maker whit below code :

###Object Functions###

-- get properties windows dc
WindowDC = __Window.GetWindowDC(hWnd);

-- create canvas from properties windows dc
Canvas = __Graphics.CanvasFromHdc(WindowDC);

-- extract my image from resource to buffer
LogoBuffer = __Plugin.ResourceExtractToBuffer(1);

-- load image binary
LogoBinary = __Graphics.ImageLoadBinary(LogoBuffer);

-- draw image on properties windows
DrawImage = __Graphics.CanvasDrawImage(Canvas, LogoBinary, 10, 40, 280, 100);

and if possible :
1) i strongly insist to draw my image with api !!
2) how to change STATIC font ??
3) how can write code that when user clicked on "Help" button of properties window, open file like "help.chm" or "help.htm" ??

can you help me, with put a example with ams plugin maker ?
respect you
i certainly dont know much about APM scripting regardless i barely inspected a bit those lua modules when i cracked it.

Im not doing an example for obvious reasons, but you are forced to fullfill same method as its done with winapi.
1) i strongly insist to draw my image with api !!
Already posted a demo code, you only have to port it to lua doing the same stuff, as i see APM does the hard work for you. Catch the WM_DRAW for your hwnd and use bitblt between begin/endpaint methods. This will lock your dc for drawing on it.
2) how to change STATIC font ??
This involve calling a method of winapi called CreateFont, then send a message to your hwnd with id WM_SETFONT and a pointer to your previuosly created font structure. Be aware of delete all those used resourced when exiting.

Simple code
SendMessage(windowHwnd, WM_SETFONT, hFont, TRUE);

3) how can write code that when user clicked on "Help" button of properties window, open file like "help.chm" or "help.htm" ??
I remember there was some scripting callback for this on APM as irPlg_ShowHelpForPlugin/Action is a exported method on the dll
so thanks pabloco