Witam.

Potrafie stworzyc prosta biblioteke i to co potrzebuje w WinApi.

Problem mam w tym, ze nei potrafie umiescic funkcji wykorzystujacej WinApi w DLL prawidlowo (chodzi mi o wywolanie okna) Moglby mi ktos to przyblizyc ? Pozdraiwam

Mam cos takiego w DEV narazie. msg box dziala jak wlacze, natomiast okno sie nie wyswietla.

/* Replace "dll.h" with the name of your header */
#include "dll.h"
#include <windows.h>

DllClass::DllClass()
{

}

DllClass::~DllClass ()
{

}

    double DLLIMPORT kwadrat( double liczba ){

    return(liczba*liczba);       
    };

HINSTANCE x;
HWND hwnd;

int APIENTRY DllMain (HINSTANCE hInst     /* Library instance handle. */ ,
                       DWORD reason        /* Reason this function is being called. */ ,
                       LPVOID reserved     /* Not used. */ )
{

                              x = hInst;

    switch (reason)
    {
      case DLL_PROCESS_ATTACH:

        break;

      case DLL_PROCESS_DETACH:
        break;

      case DLL_THREAD_ATTACH:

        break;

      case DLL_THREAD_DETACH:
        break;
    }

    /* Returns TRUE on success, FALSE on failure */
    return 1;
}

LRESULT CALLBACK WndProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
    switch( msg )
    {
    case WM_CLOSE:
        DestroyWindow( hwnd );
        break;

    case WM_DESTROY:
        PostQuitMessage( 0 );
        break;

        default:
        return DefWindowProc( hwnd, msg, wParam, lParam );
    }
}

int okno(  )
{

   //MessageBox( NULL, "TEXT", "main", MB_OK | MB_ICONWARNING | MB_DEFBUTTON2 | MB_OKCANCEL );

    WNDCLASSEX wc;

   HWND hWin = GetActiveWindow();
  // HINSTANCE hInstance = GetWindowLong( hWin, GWL_HINSTANCE);

    wc.cbSize = sizeof( WNDCLASSEX );
    wc.style = 0;
    wc.lpfnWndProc = WndProc; //obsluga komunikatow
    wc.cbClsExtra = 0;
    wc.cbWndExtra = 0;
    wc.hInstance = (HINSTANCE)GetWindowLong( hWin, GWL_HINSTANCE);
    wc.hIcon = LoadIcon( NULL, IDI_APPLICATION );
    wc.hCursor = LoadCursor( NULL, IDC_ARROW );
    wc.hbrBackground =( HBRUSH )( COLOR_WINDOW + 1 ); //kolor tla
    wc.lpszMenuName = NULL;
    wc.lpszClassName = "Nazwa_Klasy";
    wc.hIconSm = LoadIcon( NULL, IDI_APPLICATION );
    wc.style = CS_DBLCLKS;

    if( !RegisterClassEx( & wc ) )
    {

        return 2;
    }

    // TWORZENIE OKNA

    hwnd = CreateWindowEx( WS_EX_CLIENTEDGE, "Nazwa_Klasy", "Nazwa_Okna", WS_OVERLAPPEDWINDOW,
    CW_USEDEFAULT, CW_USEDEFAULT, 500, 500, NULL, NULL, x, NULL );

    if( hwnd == NULL ) return 3;

    ShowWindow( hwnd, 1 ); // Pokaż okienko...
    UpdateWindow( hwnd );
}