Che Posted September 29, 2015 Report Share Posted September 29, 2015 Am un windows form application in Visual C++ .Net, cu mai multe butoane.Cum fac ca atunci cand trec cu mouseul peste butoane acestea sa-si schimbe culoarea dupa care, cand nu mai stau cu mouseul deasupra lor sa-si revina la culoarea initiala ?Am gasit pe google chestia asta:// To use this example create a new form and paste this class // forming the same file, after the form class in the same file. // Add a button of type FunButton to the form. public ref class FunButton: public Button{protected: virtual void OnMouseHover( System::EventArgs^ e ) override { // Get the font size in Points, add one to the // size, and reset the button's font to the larger // size. float fontSize = Font->SizeInPoints; fontSize += 1; System::Drawing::Size buttonSize = Size; this->Font = gcnew System::Drawing::Font( Font->FontFamily,fontSize,Font->Style ); // Increase the size width and height of the button // by 5 points each. Size = System::Drawing::Size( Size.Width + 5, Size.Height + 5 ); // Call myBase.OnMouseHover to activate the delegate. Button::OnMouseHover( e ); } virtual void OnMouseMove( MouseEventArgs^ e ) override { // Make the cursor the Hand cursor when the mouse moves // over the button. Cursor = Cursors::Hand; // Call MyBase.OnMouseMove to activate the delegate. Button::OnMouseMove( e ); }https://msdn.microsoft.com/en-us/library/system.windows.forms.control.onmousehover.aspxNumai ca nu merge.Stie cineva ?Multumesc mult ! Quote Link to comment Share on other sites More sharing options...
FarSe Posted September 29, 2015 Report Share Posted September 29, 2015 OnMouseEnter : schimbi culoarea in ce vrei tu;OnMouseLeave : schimbi culoarea in default;https://msdn.microsoft.com/en-us/library/system.windows.forms.control.onmouseenter(v=vs.110).aspxhttps://msdn.microsoft.com/en-us/library/system.windows.forms.control.onmouseleave(v=vs.110).aspx Quote Link to comment Share on other sites More sharing options...
Erase Posted September 29, 2015 Report Share Posted September 29, 2015 (edited) Intai de toate trebuie sa-ti declari event-urile in forma in care vei folosi acel buton.Dupa ce ai facut asta in cadrul event-urilor apelezi proprietatiile butonului pentru a schimba ceea ce vrei.LE: Mai offtopic asa; poti sa-mi spui de ce scrii in C++ pe platforma .Net avand in vedere ca limbajul in care e compilat este acelasi si nu aduce nici o imbunatatire in momentul rularii? Microsoft a scos acel template tocmai pentru a incuraja dezvoltatorii sa foloseasca C# sau VB daca vor sa creeze o aplicatie de tip win forms iar C++ sa se foloseasca la aplicatii native. Edited September 29, 2015 by Erase Quote Link to comment Share on other sites More sharing options...
Che Posted September 29, 2015 Author Report Share Posted September 29, 2015 OnMouseEnter : schimbi culoarea in ce vrei tu;OnMouseLeave : schimbi culoarea in default;https://msdn.microsoft.com/en-us/library/system.windows.forms.control.onmouseenter(v=vs.110).aspxhttps://msdn.microsoft.com/en-us/library/system.windows.forms.control.onmouseleave(v=vs.110).aspxDa-mi un exemplu de cum se foloseste chestia asta intr-un windows from app. ca nu reusesc sa o implementez.Multumesc ! @EraseM-am hotarat sa scap de tendintele de a invatat VB.net si/sau C# si alte derivatii. Quote Link to comment Share on other sites More sharing options...
curiosul Posted September 29, 2015 Report Share Posted September 29, 2015 IDE-ul iti genereaza automat acele eventuri de care ai tu nevoie. In visual studio urmeaza pasii:1. Click pe butonul respectiv.2. Mergi la categoria events (fulgerul)3. Dublu click pe MouseMove si MouseLeave, si te va redirectiona spre blocul in care bagi cod pentru fiecare. In MouseMove setezi o culoare si respectiv in MouseLeave cealalta.Succes. Quote Link to comment Share on other sites More sharing options...
Erase Posted September 29, 2015 Report Share Posted September 29, 2015 (edited) Adica C# si VB deriva din C++ .Net? Daca ai facut afirmatia asta cred ca nu cunosti arhitectura acestei platforme.Inainte sa lucrezi in .Net te sfatuiesc sa inveti ce inseamna.Poti incepe de aici: https://en.wikipedia.org/wiki/.NET_Framework. Edited September 29, 2015 by Erase Quote Link to comment Share on other sites More sharing options...
Che Posted September 29, 2015 Author Report Share Posted September 29, 2015 Nu am zis ca deriva, doar ca nu e sigur. Codul poate fi decompilat si munca ta iti este furata de orice incepator. @curiosulMultumesc mult de tot ! Quote Link to comment Share on other sites More sharing options...
watsonAI Posted September 29, 2015 Report Share Posted September 29, 2015 Che, Tu acolo lucrezi in c++/cli care de fapt e un fel de c#.net doar ca sintaxa este de c++. In principiu, din cate stiu, se foloseste de aceleasi librarii ca si c#, si codul generat este similar, pentru ca este cod managed. Daca vrei sa lucrezi in c++ pur, atunci iti sugerez sa incerci una din librariile multi platform pentru gui(qt si wxwidgets sunt cele mai folosite). Quote Link to comment Share on other sites More sharing options...
gigiRoman Posted September 29, 2015 Report Share Posted September 29, 2015 Dar stiu ca toate limbajele .net folosesc Common intermediate language. Deci e acelasi lucru indiferent de limbajul folosit. @Che pt decompilare poti folosi de la jet brains just decompile parca se cheama. Quote Link to comment Share on other sites More sharing options...