الفريق العربي للبرمجةأرشيف المنتديات · 2000 – 2023
نسخة أرشيفية للقراءة فقط — التسجيل والمشاركة مغلقان، والمحتوى محفوظ كما كان.

البرمجة من خلال API

مغلق
بدأه Nokia_2006 في 17 يناير 2006 · 1 رد · 449 مشاهدة · في لغة Assembly لأنظمة 16, 32, 64 بت
مشاركة: واتساب X فيسبوك تيليجرام
#1 صاحب الموضوع

السلام عليكم يا شباب

اولا : فى مشكلة محيارانى

وهى

استخدام API مع الاسمبلى لكن انا اعرف انها تتم عن طريق عملية PASH و CALL هذا بالنسبة للتعليمة MASSEGBOX

ممكن وبسيطة ولكن ماذا عن التعامل مع كود كمثل فئة تسجيل النافذة WNDCLASSe cx

حيث انها تشمل الخصائص Cx.size و cx.icon

وهكذا

ولا استخدم مباشرة الدالة CREATWINDOWS

وهذا مثال : بسيط كيف اعالجه بالاسمبلى

LRESULT CALLBACK WndProc(HWND hwnd,UINT Message,WPARAM wParam,LPARAM lParam);
//=========================================================================================
//start the application; all win32 applications require a WinMain function
//that the windows operating system looks for as an entry point to that application
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nCmdShow)
{
HWND    hwnd;    //the wnd handle
MSG     Msg;     //a simple structure for storing message information
HICON   hIcon;   //window icon
HCURSOR hCursor; //window cursor
//declare and initialise wnd registration information variables
TCHAR chClassName[]=TEXT("SIMPLEWND");
WNDCLASSEX wcx;    //this structure is used for storing information about the wnd 'class'
//use 'LoadImage' to load wnd class icon and cursor as it supercedes the obsolete functions
//'LoadIcon' and 'LoadCursor', although these functions will still work. Because the icon and
//cursor are loaded from system resources ie they are shared, it is not necessary to free the
//image resources with either 'DestroyIcon' or 'DestroyCursor'.
hIcon=(HICON)LoadImage(0,IDI_APPLICATION,IMAGE_ICON,0,0,LR_SHARED);
hCursor=(HCURSOR)LoadImage(0,IDC_ARROW,IMAGE_CURSOR,0,0,LR_SHARED);
wcx.cbSize           = sizeof(WNDCLASSEX);              //byte size of WNDCLASSEX struct
wcx.style            = CS_HREDRAW|CS_VREDRAW;           //ensure wnd is always redrawn
wcx.lpfnWndProc      = (WNDPROC)WndProc;                //pointer to the Window Procedure
wcx.cbClsExtra       = 0;                               //Extra bytes for 'class' wnds
wcx.cbWndExtra       = 0;                               //Extra bytes for this wnd
wcx.hInstance        = hInstance;                       //Application instance
wcx.hIcon            = hIcon;                           //Application icon
wcx.hCursor          = hCursor;                         //Cursor for wnd
wcx.hbrBackground    = (HBRUSH)(COLOR_BTNFACE+1);       //Background wnd colour
wcx.lpszMenuName     = NULL;                            //Name of wnd menu
wcx.lpszClassName    = chClassName;                     //Name of this wnd 'class'
wcx.hIconSm          = NULL;                            //Icon in top-left corner of wnd
//Register the wnd class with the Windows system
if (!RegisterClassEx(&wcx))
    {
    //Registration has failed so inform the user
    MessageBox( NULL,
                TEXT("Failed to register wnd class"),
                TEXT("ERROR"),
                MB_OK|MB_ICONERROR);
    return FALSE;
    }
//create wnd of the 'class' just registered
hwnd=CreateWindowEx(0,                                  //more or 'extended' styles
                    chClassName,                        //the 'class' of window to create
                    TEXT("Simple Window"),              //the window title
                    WS_OVERLAPPEDWINDOW,                //window style: how it looks
                    GetSystemMetrics(SM_CXSCREEN)/4,    //window position: left
                    GetSystemMetrics(SM_CYSCREEN)/4,    //window position: top
                    GetSystemMetrics(SM_CXSCREEN)/2,    //window width
                    GetSystemMetrics(SM_CYSCREEN)/2,    //window height
                    NULL,                               //parent window handle
                    NULL,                               //handle to this windows's menu
                    hInstance,                          //application instance
                    NULL);                              //user defined information
if (!hwnd)
    {
    //wnd creation has failed so inform the user  
    MessageBox( NULL,
                TEXT("Failed to create wnd"),
                TEXT("ERROR"), 
                MB_OK|MB_ICONERROR);
    return FALSE;
    }
//Display the wnd
ShowWindow(hwnd,nCmdShow); 
UpdateWindow(hwnd);
//start message loop
while (GetMessage(&Msg,NULL,0,0)>0)
    {
    TranslateMessage(&Msg);
    DispatchMessage(&Msg);
    }
return Msg.wParam;
}
//=========================================================================================
LRESULT CALLBACK WndProc(HWND hwnd,UINT Message,WPARAM wParam,LPARAM lParam)
{
switch (Message)
    {
    case WM_DESTROY:
        PostQuitMessage(0);    //signal end of application
        return 0;
    default:
        return DefWindowProc(hwnd,Message,wParam,lParam);  //let system deal with msg
    }
}
//=========================================================================================

هل فى الاسمبلى مطلوب منى كل هذا لبناء نافذة

علما با ان بناء نافذة يتطلب وجود حلقة رسائل خاصة بها وكل نافذة لها حلقة رسائل خاصة بها

كيف اكتب نافذة كاملة واستخدم

وياريت لو فى كتاب يحدث عن الاسمبلى مع API اكون شاكرا لكم

تم تعديل هذه المشاركة بواسطة Nokia_2006 في 17 يناير 2006 في 00:20

#2

تم شرح هذا الموضوع اكثر من خمسين مرة

لا إله إلا الله محمد رسول الله

busbar : يجب ان تدرك انه هناك حد ادنى للمعرفة المطلوبة قبل البدء في عمل أي شئ.

هذا الموضوع مغلق.

مواضيع مشابهة