Hi everyone,
Can you have a quick look and tell me why the caret is not shown , any help will be greatly appreicated
thank you.
using System;
using System.Drawing;
using System.Collecti ons;
using System.Componen tModel;
using System.Windows. Forms;
using System.Data;
using System.Runtime. InteropServices ;
namespace test
{
public class Form1 : System.Windows. Forms.Form
{
private System.Windows. Forms.Button button1;
private System.Windows. Forms.Button button2;
private System.Componen tModel.Containe r components = null;
public Form1()
{
InitializeCompo nent();
}
protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Disp ose();
}
}
base.Dispose( disposing );
}
#region Windows Form Designer generated code
private void InitializeCompo nent()
{
this.button1 = new System.Windows. Forms.Button();
this.button2 = new System.Windows. Forms.Button();
this.SuspendLay out();
//
// button1
//
this.button1.Lo cation = new System.Drawing. Point(456, 240);
this.button1.Na me = "button1";
this.button1.Ta bIndex = 2;
this.button1.Te xt = "button1";
this.button1.Cl ick += new System.EventHan dler(this.butto n1_Click);
//
// button2
//
this.button2.Lo cation = new System.Drawing. Point(456, 280);
this.button2.Na me = "button2";
this.button2.Ta bIndex = 3;
this.button2.Te xt = "button2";
this.button2.Cl ick += new System.EventHan dler(this.butto n2_Click);
//
// Form1
//
this.AutoScaleB aseSize = new System.Drawing. Size(5, 13);
this.ClientSize = new System.Drawing. Size(616, 334);
this.Controls.A dd(this.button2 );
this.Controls.A dd(this.button1 );
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHan dler(this.Form1 _Load);
this.ResumeLayo ut(false);
}
#endregion
[STAThread]
static void Main()
{
Application.Run (new Form1());
}
[DllImport("User 32.dll", CharSet=CharSet .Auto)]
public static extern bool SetCaretPos(int X, int Y);
[DllImport("User 32.dll", CharSet=CharSet .Auto)]
public static extern bool ShowCaret(IntPt r hWnd);
[DllImport("User 32.dll", CharSet=CharSet .Auto)]
public static extern bool HideCaret(IntPt r hWnd);
private void Form1_Load(obje ct sender, System.EventArg s e)
{
}
private void button2_Click(o bject sender, System.EventArg s e)
{
HideCaret(this. Handle);
}
private void button1_Click(o bject sender, System.EventArg s e)
{
ShowCaret(this. Handle);
SetCaretPos(10, 10);
}
}
} 2 3696
Just a hint: maybe it is necessary to create a caret at fist via
CreateCaret?.
if SetCaretPos returns false, try to obtain error code with GetLastError (
kernel32.dll )
--
Vadym Stetsyak aka Vadmyst
<Co**********@a l.com> wrote in message
news:uk******** *********@newsf e5-gui.ntli.net... Hi everyone, Can you have a quick look and tell me why the caret is
not shown , any help will be greatly appreicated thank you.
using System; using System.Drawing; using System.Collecti ons; using System.Componen tModel; using System.Windows. Forms; using System.Data; using System.Runtime. InteropServices ;
namespace test {
public class Form1 : System.Windows. Forms.Form { private System.Windows. Forms.Button button1; private System.Windows. Forms.Button button2;
private System.Componen tModel.Containe r components = null;
public Form1() {
InitializeCompo nent();
}
protected override void Dispose( bool disposing ) { if( disposing ) { if (components != null) { components.Disp ose(); } } base.Dispose( disposing ); }
#region Windows Form Designer generated code
private void InitializeCompo nent() { this.button1 = new System.Windows. Forms.Button(); this.button2 = new System.Windows. Forms.Button(); this.SuspendLay out(); // // button1 // this.button1.Lo cation = new System.Drawing. Point(456, 240); this.button1.Na me = "button1"; this.button1.Ta bIndex = 2; this.button1.Te xt = "button1"; this.button1.Cl ick += new System.EventHan dler(this.butto n1_Click); // // button2 // this.button2.Lo cation = new System.Drawing. Point(456, 280); this.button2.Na me = "button2"; this.button2.Ta bIndex = 3; this.button2.Te xt = "button2"; this.button2.Cl ick += new System.EventHan dler(this.butto n2_Click); // // Form1 // this.AutoScaleB aseSize = new System.Drawing. Size(5, 13); this.ClientSize = new System.Drawing. Size(616, 334); this.Controls.A dd(this.button2 ); this.Controls.A dd(this.button1 ); this.Name = "Form1"; this.Text = "Form1"; this.Load += new System.EventHan dler(this.Form1 _Load); this.ResumeLayo ut(false);
} #endregion
[STAThread] static void Main() { Application.Run (new Form1()); }
[DllImport("User 32.dll", CharSet=CharSet .Auto)] public static extern bool SetCaretPos(int X, int Y);
[DllImport("User 32.dll", CharSet=CharSet .Auto)] public static extern bool ShowCaret(IntPt r hWnd);
[DllImport("User 32.dll", CharSet=CharSet .Auto)] public static extern bool HideCaret(IntPt r hWnd);
private void Form1_Load(obje ct sender, System.EventArg s e) {
}
private void button2_Click(o bject sender, System.EventArg s e) { HideCaret(this. Handle); }
private void button1_Click(o bject sender, System.EventArg s e) { ShowCaret(this. Handle); SetCaretPos(10, 10); }
}
}
Just a quick tip about DLLImport.
If you want GetLastError to actually work for you, I suggest adding the
SetLastError=Tr ue to the DllImport.
For example:
[DllImport("User 32.dll", CharSet=CharSet .Auto, SetLastError=Tr ue)]
public static extern bool HideCaret(IntPt r hWnd);
This will make sure the LastError IS set when existing this function.
Eran
=============== =============== =============== ============= http://dotnetdebug.blogspot.com - Advanced .NET Debugging Blog
The place for WinDbg, SOS, Live and post mortem debugging. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jason |
last post by:
Hello,
I am using Dev c++ to create a dll in c++ on windows xp pro. It provided me
with a template and I added a simple function to return an int as a test.
It compiled the dll ok and I added a reference to a Visual basic 6 project,
yet when I call it VB complains about run time error 453, "cant find dll
entry point 'funcname'". Can anybody show me what I am doing wrong, do I
need to create a definition file and if so how?
I have...
|
by: Webdiyer |
last post by:
I want to integrate SecurID two-factor authentication system of the
RSASecurity.inc into our asp.net application,but I get into trouble when
trying to call the API functions of the ACE Agent,I got an error message
saying "Cannot marshal parameter #2: Invalid managed/unmanaged type
combination (this value type must be paired with Struct)" when calling
"AceGetPinParams(iHandle,ref sd_pin)" function,here's my test code:
private static...
|
by: David++ |
last post by:
Hi there,
I have built a DLL in Visual C++ 6. When I build the DLL it builds fine for
the debug version of the DLL (and this DLL works fine), however, I seem
unable to build a Release version of the DLL. If I do a 'Batch Build' and
select both Debug and Relase versions for building it will build the debug
version but throws up errors for the Release version. For example, the output
I get for a Batch Build is this -
...
|
by: AussieRules |
last post by:
Hi,
I want to use the user color scheme to set the color of my forms.
I now I have to use the. System.Drawing.SystemColors, but which color is the
color of a form background as used in other applications.
In the end all I want to do is
form1.backcolor = system.whatever.color
|
by: Vizzybit |
last post by:
I am attempting to utilise the HBAAPI.dll that can be found at
http://hbaapi.sourceforge.net/ (which is also used in hbaverify at
http://hbaverify.sourceforge.net/) as I need to get a small subset of the
data that it provides. However, although I can get the initialisations to
work, I cannot manage to get responses that require data to pass to the dll.
(The latest API details are at :
ftp://ftp.t11.org/t11/pub/sm/hba/05-056v0.pdf)
The...
| |
by: justin.kruger |
last post by:
I am having a problem with exchanging handles with c# and the
"CP210xManufacturing.dll" in a device wrapper that i am working on.
I have created a wrapper class to address some of the functions in the
dll, but not all of them yet. To my knowledge they should be almost
correct, however this is my first try at exchanging handles between
legacy code and a managed enviroment. It seems that I am able to get a
handle from "CP210x_Open,"...
|
by: Rene |
last post by:
Hello to all!
For a long time I have been "fighting" a problem compiling an OpenGL
program which uses GLUT. First I have put a question in a Watcom group
(I want to use this compiler) to which I got no reply, in an OpenGL
group somebody recommended me to use Visual C++ which I did. That worked
OK but I do would like to use Watcom.
In the meantime I found solutions to several of the errors I got but one
is left which I cannot find a...
|
by: JohnCox |
last post by:
I have a simple Win32 DLL I wrote named "SimpleLib" that exports two functions. It is written in C++ and compiled with __stdcall (/Gz) and with the preprocessor definition _MBCS (not Unicode).
The first function is called "StrFirst" and takes in a LPTSTR as the first parameter and a long as the second, like this:
SIMPLELIB_API int StrFirst(LPTSTR str, long num);
The second function is essentially the same thing, but with the order of the...
|
by: mrssuper |
last post by:
Hey All,
How do I declare a following types:
char**
unsigned char**
in C# DllImport function?
|
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...
|
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...
| |
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...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
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...
| |