473,396 Members | 1,998 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to Activate A Control Added to Desktop

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::Req uestMinimum, 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 & cant able to use my mouse events.



I want to focus on listbox.



Plz Suggest me .........



Thanks in advance


Nagaraju
Jun 26 '07 #1
1 1409
kenobewan
4,871 Expert 4TB
Here is an article that may help:
Injecting Dynamic JavaScript to Focus ASP.NET Controls
Jun 28 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: LarsJ | last post by:
Hi, can please MS answer this question: Is there any way for an desktop application to make it the active application (= the application window is highlighted and in front)? Or is there any way...
7
by: Will | last post by:
I'm working on a C# Windows Service that needs to monitor serial port communication. Because the .Net framework does not include support for serial communications, I've decided to use the...
10
by: zhou | last post by:
in Visual Basic ,I use Appactivate(AcadApp.caption);
2
by: MattB | last post by:
How would I have a textbox on my web form that will automatically have a blinking cursor in it when the page loads? Closest I've come so far is having to press tab once to put the cursor in there....
5
by: Adda | last post by:
In a Parent mdi form I have a datagrid. I select a record from the grid and then invoke a childmdi form. I add the childmdi to an arraylist to keep track of it. If a user has selected multiple...
2
by: fniles | last post by:
For IE users, we now encountered a "Click to activate and use this control" when the web page has an ActiveX Control. There is a compatibility patch that changes the default bahavior back to what...
8
by: =?Utf-8?B?cmtibmFpcg==?= | last post by:
How can I make the 'Menu & Toolbars' menu active in the toolbox? Right now I can see the options, but not been able to select items.
2
by: CGatto | last post by:
Hi, I have Windows Form with several User Controls embedded within. Only one user control is visible at any one time. The user moves through the various user controls by clicking Previous and...
7
by: Andrus | last post by:
I have UserControls in MDI child forms containing TextBoxes and other controls. When user re-activates form, I need that Control which was last activated is activated again. Currently *first*...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.