Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. How to Activate A Control Added to Desktop

How to Activate A Control Added to Desktop

Scheduled Pinned Locked Moved .NET (Core and Framework)
securitytutorial
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Nagaraju_Focus
    wrote on last edited by
    #1

    I have Created A ListBox Control Whose Handle is Desktop. My code for ListBox: #using using namespace System; using namespace System::ComponentModel; using namespace System::Collections; using namespace System::Windows::Forms; using namespace System:ata; using namespace System:rawing; using namespace System::Runtime::InteropServices; using namespace System::Security::Permissions; namespace DeskTopTest { /// /// Summary for MyListBox /// // Requires unmanaged code [assembly: SecurityPermissionAttribute (SecurityAction::RequestMinimum, UnmanagedCode=true)]; // Requires ability to create any window type [assembly:UIPermissionAttribute(SecurityAction::RequestMinimum, Window=UIPermissionWindow::AllWindows)]; public ref class MyListBox : public ListBox { public: MyListBox(void) { } protected: virtual property System::Windows::Forms::CreateParams^ CreateParams { virtual System::Windows::Forms::CreateParams^ get() override { const int WS_EX_TOOLWINDOW = 0x00000080; const int WS_EX_NOACTIVATE = 0x08000000; const int WS_EX_TOPMOST = 0x00000008; try { System::Windows::Forms::CreateParams ^p =ListBox::CreateParams; p->ExStyle |= (WS_EX_NOACTIVATE | WS_EX_TOOLWINDOW | WS_EX_TOPMOST); p->Parent = IntPtr::Zero; return p; } catch (Exception^ e) { return nullptr; } } } public:[DllImport("user32.dll")] static int SetParent( IntPtr hWndChild, IntPtr hWndNewParent); [DllImport("user32.dll")] static int ShowWindow( IntPtr hWnd, int nCmdShow); [DllImport("user32.dll")] static IntPtr GetDesktopWindow(void); public: void ShowFloating() { if (this->Handle == IntPtr::Zero) { ListBox::CreateControl(); } //IntPtr s=GetDesktopWindow(); int x=SetParent(ListBox::Handle, IntPtr::Zero); x=ShowWindow(ListBox::Handle,1); } protected: virtual void WndProc(Message% m)override { ListBox::WndProc(m); } }; } but when i Added this listbox to my form like: MyListBox ^lst=gcnew MyListBox(); lst->Location=System:rawing::Point(264, 166); lst->Name = L"comboBox1"; lst->TabIndex = 1; lst->Visible=false; lst->Size = System:rawing::Size(171, 200); for (UInt16 i=1;i<100;i++) { lst->Items->Add("Item"+i.ToString()); } lst->ShowFloating(); and calling the function ShowFloating(); It is working fine. But I cant unable to focus On my Listbox & can

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups