6 mensajes Página 1 de 1
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
Imagen
life is beauty
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.

case WM_CREATE:
        hBitmap = (HBITMAP)LoadImage(hInst, L"c:\\test.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
        break;
    case WM_PAINT:
        PAINTSTRUCT     ps;
        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);
        DeleteDC(hdcMem);

        EndPaint(hWnd, &ps);
Parsed in 0.003 seconds, using GeSHi 1.0.8.9
ImagenImagenImagenImagen
you can do that by Ams Plugin Maker Easily
Imagen
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;
        end

                return false;
end
 
Parsed in 0.002 seconds, using GeSHi 1.0.8.9


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;
        end

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

        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;
                                end
                        end
        end

return false;
end
 
Parsed in 0.004 seconds, using GeSHi 1.0.8.9


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);
 
Parsed in 0.002 seconds, using GeSHi 1.0.8.9


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
Imagen
life is beauty
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
HFONT hFont = CreateFont (13, 0, 0, 0, FW_DONTCARE, FALSE, FALSE, FALSE, ANSI_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, TEXT("Tahoma"));
SendMessage(windowHwnd, WM_SETFONT, hFont, TRUE);
Parsed in 0.002 seconds, using GeSHi 1.0.8.9


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
ImagenImagenImagenImagen
so thanks pabloco
Imagen
life is beauty
6 mensajes Página 1 de 1

¿Quién está conectado?

Usuarios navegando por este Foro: elroock y 1 invitado