473,699 Members | 2,311 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C#-App: Saving the previous focus

71 New Member
hi everyone,

I am loading a flash game(shockwave flash object) using the panel in c# Winforms. Everytime the game will need to let the player to input some text I want to provide a virtual keyboard. But my problem is how to identify the focus from that flash game. What API do i need to use to save that focus so I can paste the inputs from my virtual keyboard.


I know this question can be easily seen when searched thoroughly, but I can't find the right combinations for the strings to search and time is running out for me. Please help me


Thanks a lot in advance

Dantz
Mar 23 '09 #1
2 2704
tlhintoq
3,525 Recognized Expert Specialist
Are you coding your own virtual keyboard, or using the windows one?

WHen I've used the Windows virtual keyboard the keystrokes automatically went to the last application that had focus before before using the keyboard.

If you are making your own then when your application creates a new VirtualKeyboard instance/object then subscribe to whatever event you raise when a key is pressed.
Mar 23 '09 #2
dantz
71 New Member
Thank you very much for the reply. Yes, I am coding my own keyboard. I forgot to tell that I also have a textbox in my virtual keyboard to make a preview of the input of the keyboard.

I also found another solution by getting the handle of the flash player.

In the form where the keyboard button was clicked (to show the virtual keyboard):

Expand|Select|Wrap|Line Numbers
  1. GameKeyboard newGameKB = new GameKeyboard (this.flashPlayer.Handle);
  2.  
  3. newGameKB .Show();
  4.  
  5.  

Then on the Keyboard form I used the "SetFocus" API coz i already have the handle from the flash player.

Expand|Select|Wrap|Line Numbers
  1. [DllImport("user32.dll")]
  2.  
  3. public static extern IntPtr SetFocus(IntPtr hWnd);
  4.  
  5. private IntPtr _prevHwnd = IntPtr.Zero;
  6.  
  7. public GameKeyboard (IntPtr prevHandle)
  8.  
  9. {
  10.  
  11.       if (prevHandle != null)
  12.  
  13.       {
  14.  
  15.             prevHwnd = prevHandle;
  16.  
  17.       }
  18.  
  19.             InitializeComponent();
  20.  
  21. }
  22.  
  23. private void KBKey_Done(object sender, EventArgs e)
  24.  
  25. {
  26.  
  27. this.Hide();
  28.  
  29. SetFocus(prevHwnd);
  30.  
  31. SendKeys.Send(this.txtKBOutput.Text);
  32.  
  33. }
  34.  
  35.  

I hope this solution would not have any problems
Mar 24 '09 #3

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

Similar topics

7
10556
by: Chris | last post by:
I'm using eight links listed horizontally as a menu on my site. I'm using font-variant:small-caps and they are padded so that they mimic buttons. My gripe is with the way IE handles the focus rectangle on these links. It insists on drawing this crazy shape that traces the text, which with small caps looks rather assinine. Firefox handles the same task very gracefully (yeah Gecko!) and I would like to force IE to do the same. The site...
4
2288
by: melanieab | last post by:
Hi, I'm trying to save a bitmap file so I can print it later. I have Image.Save("sImage.bmp",System.Drawing.Imaging.ImageFormat.Bmp); The file sImage.bmp shows up in the bin\debug folder but when I try to print it (or open it), it's completely black. I know Image is the correct picture because when I immediately print it, it works. What am I doing wrong? Thanks! Melanie
1
5043
by: cider123 | last post by:
I've tried working with the SelectedIndices and Items.Selected attributes to get the problem to go away, but not having any luck. Questions I have are: 1) How do you move (using code) the focus Rectangle when your Selected Index changes ? 2) If there are no selected rows, can that focus rectangle be removed? 3) What other quirks exist in this simple example I might need to code for ?
2
1244
by: Sam | last post by:
Hi all Is there an easy way to find the previous Cell or Row that user just left on DataGrid Control or Table. For example, if I'm currently on Row 1 Column 2 and then I click on Row 3 Column 5. Is it possible to know the previous location of my focus? What I'm trying to do is that if user changed content of a row, I want to update my variables to reflect that. Thanks in advance
2
5400
by: Sid Price | last post by:
Is there a way of stopping a form getting focus in VB.NET. The scenario I have is a main form and a form used for display only. There are no user controls on the display form and it does not ever need to have the focus. When the displays on the form are updated it appears to get the focus. I would like to prevent this because if the user operates any hot-keys (thinking the main form still has focus) these keys will fail. I have tried...
1
3233
by: google | last post by:
I have a form with several subforms. Users enter the data, then on the parent there is a command button that runs code to generate a .pdf document from a report based on the data they are working with. If a user enters data in a subform, then directly clicks the command button on the parent form, the data in the subform is not included in their document. I THOUGHT that as soon as focus left the subform, any pending changes to the data...
9
2394
by: Wingot | last post by:
Hey, I am using Visual Studio 2008 Beta 2 for some application development in C#, but I presume that the following question applies equally well to any environment.
0
1578
by: ll | last post by:
I'm currently working with an ASP page that populates rows based on a query for course data by using a DO WHILE NOT EOF loop. An improvement I'm adding is a dropdown populated by query which shows each course number, so that the user can populate that course page with data from a previous course. My question is: once the data from the previous course is populating the current course page (after being selected from the aforementioned...
5
1804
by: wassimdaccache | last post by:
Hello sirs; I do have a continuous form on MS access 2003 I would like to filter this form using the content of the field. I am using this code. Dim y, x As String y = Application.Screen.PreviousControl.Name x = Application.Screen.PreviousControl.Value
0
8685
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8613
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9172
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8880
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7745
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6532
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4374
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2344
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.