Jump to content

[C++] Button Function [WindowTaple]


Recommended Posts

Posted

هذا كود لي زر في , برنامج بسيط يسوي شي معين لما اضغط عليه

لاكن ادا ضفت 2 ازرار وحطيط فانكشن لكل زر ..

لما اضغط علي زر يسوي نفس الوظيفه الاولي ثاني ؟؟ .. ها يلا وروني الحل 

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)  
{  

    PAINTSTRUCT ps;
    HDC hdc;
    TCHAR greeting[] = _T("TEXT IN THE TAPLE!");
    static HWND hButton;


    switch (message)
    {

    case WM_CREATE:
      // الزر
       hButton = CreateWindow( L"button", L"text in button",
                WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON,
                50, 100,  // احداثيات لمكان الزر والحجم
                110, 40,  // احداثيات لمكان الزر والحجم
                hWnd, (HMENU) BUTTON_ID, // button_id موجود في define
                hInst, NULL );
          // لو اضيف كمان زر  واروح تحت اسويله الكومند حقه = يصير لو اضغط علي زر فيهم يسويلي الوظيفه الاولي + الوظيفه حقت الزر الثاني !
      break;
 
    case WM_PAINT:
        hdc = BeginPaint(hWnd, &ps);

 
        TextOut(hdc,
            5, 5,
            greeting, _tcslen(greeting));
        

        EndPaint(hWnd, &ps);
        break;

		case WM_COMMAND: // كيس الضغط الكومند
        	   if(hButton) // ادا حدث الزر الي فوق .. يحصل الفاكشن الي تحت
	   {
		   	      func Func(0);
	hinstDLL = LoadLibrary(L"Loader.dll"); // load dll form folder .
	if(hinstDLL != 0)
	{
		Func = (func)GetProcAddress(hinstDLL, "Func");

	}
	Func(0);
	FreeLibrary(hinstDLL);

	return 0;
	   }
        
	break;

    case WM_DESTROY:
        PostQuitMessage(0);
        break;
    default:
        return DefWindowProc(hWnd, message, wParam, lParam);
        break;
    }

    return 0;
}  

:):) قد يكون معي الحل ولاكن انا اري ان كان مبرمجين لهذه الغه هنا :):)

works at MCC

p_11078thil1.jpg

@NmLa

Posted (edited)

بسيطة ..
 

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)  
{  

    PAINTSTRUCT ps;
    HDC hdc;
    TCHAR greeting[] = _T("TEXT IN THE TAPLE!");
    static HWND hButton;


    switch (message)
    {

    case WM_CREATE:
       hButton = CreateWindow( L"button", L"text in button",
                WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON,
                50, 100, 
                110, 40,
                hWnd, (HMENU) BUTTON_ID, 
                hInst, NULL );
       hButton1 = CreateWindow( L"button", L"text in button",
                WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON,
                50, 100, 
                110, 40, 
                hWnd, (HMENU) BUTTON_ID,
                hInst, NULL );
      break;
 
    case WM_PAINT:
        hdc = BeginPaint(hWnd, &ps);

 
        TextOut(hdc,
            5, 5,
            greeting, _tcslen(greeting));
        

        EndPaint(hWnd, &ps);
        break;

		case WM_COMMAND:
        	   if(hButton || hButton1) 
	   {
		   	      func Func(0);
	hinstDLL = LoadLibrary(L"Loader.dll"); 
	if(hinstDLL != 0)
	{
		Func = (func)GetProcAddress(hinstDLL, "Func");

	}
	Func(0);
	FreeLibrary(hinstDLL);

	return 0;
	   }
        
	break;

    case WM_DESTROY:
        PostQuitMessage(0);
        break;
    default:
        return DefWindowProc(hWnd, message, wParam, lParam);
        break;
    }

    return 0;
}  

شكراً على التوضيح بعض الاشياء قدرت اعرف الحل من توضيحك : )
 

Edited by iMr.WiFi..!
|| not &&

Experienced MTA developer for 4 years. | MTA خبرة 4 سنين في برمجة

ليس عليك اسعاد الجميع ,
ولكن عليك بإن لا تؤذي أحداً 

=========
You do not have to make everyone happy,
But you should not hurt anyone

 

Want to contact with me?

 

Discord: JustCarry#2616 (Always there)
Skype: Live:JustCarry10 (Not always)

Posted
2 hours ago, iMr.WiFi..! said:

بسيطة ..
 


LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)  
{  

    PAINTSTRUCT ps;
    HDC hdc;
    TCHAR greeting[] = _T("TEXT IN THE TAPLE!");
    static HWND hButton;


    switch (message)
    {

    case WM_CREATE:
       hButton = CreateWindow( L"button", L"text in button",
                WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON,
                50, 100, 
                110, 40,
                hWnd, (HMENU) BUTTON_ID, 
                hInst, NULL );
       hButton1 = CreateWindow( L"button", L"text in button",
                WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON,
                50, 100, 
                110, 40, 
                hWnd, (HMENU) BUTTON_ID,
                hInst, NULL );
      break;
 
    case WM_PAINT:
        hdc = BeginPaint(hWnd, &ps);

 
        TextOut(hdc,
            5, 5,
            greeting, _tcslen(greeting));
        

        EndPaint(hWnd, &ps);
        break;

		case WM_COMMAND:
        	   if(hButton || hButton1) 
	   {
		   	      func Func(0);
	hinstDLL = LoadLibrary(L"Loader.dll"); 
	if(hinstDLL != 0)
	{
		Func = (func)GetProcAddress(hinstDLL, "Func");

	}
	Func(0);
	FreeLibrary(hinstDLL);

	return 0;
	   }
        
	break;

    case WM_DESTROY:
        PostQuitMessage(0);
        break;
    default:
        return DefWindowProc(hWnd, message, wParam, lParam);
        break;
    }

    return 0;
}  

شكراً على التوضيح بعض الاشياء قدرت اعرف الحل من توضيحك : )
 

هههه متاكد ان مش ناقصك شي ؟ 

لازم تحط 

static HWND hButton, hButton1; 

او تحط كل واحد لواحده 

static HWND hButton;
static HWND hButton1;

لاكن مازال الكود خطأ ههه , قد يكون حل بطريقه اخري ههه

works at MCC

p_11078thil1.jpg

@NmLa

Posted

مايصلح نستعمل 
؟؟

case hButton, hButton1;

Experienced MTA developer for 4 years. | MTA خبرة 4 سنين في برمجة

ليس عليك اسعاد الجميع ,
ولكن عليك بإن لا تؤذي أحداً 

=========
You do not have to make everyone happy,
But you should not hurt anyone

 

Want to contact with me?

 

Discord: JustCarry#2616 (Always there)
Skype: Live:JustCarry10 (Not always)

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...