473,626 Members | 3,443 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Having problems with SetWindowText api

Hello all!

I'm writing because I'm having some problems with the SetWindowText api
(Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA "
(ByVal hwnd As Long, ByVal lpString As String) As Long)

I know the handle, and have the string what i want to see in the title.
Here is the code part:
c = SetWindowText(h wnd, "string")

c should be a double which is not null, it is ok because c returns a
good value every time
but after that
the window's caption should be "string", but it's became empty, not
"string".

i tried another way too. It is the SendMessage function.

we have the handle and the string again, and there is the code:
c = SendMessage(hwn d, 12, vbNull, "string")

c returns 1 so it should be ok
but the caption's text not ok again. it not empty but contains only one
character a Chr(8). if i replace the "string" with a vbNullString then
the caption text is empty again.

How can i set the right text in the caption?

Thanks,

Bence (iecs)

Oct 23 '06 #1
2 6671
>I'm writing because I'm having some problems with the SetWindowText api
>(Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA "
(ByVal hwnd As Long, ByVal lpString As String) As Long)
Make that

Declare Auto Function SetWindowText Lib "user32" (ByVal hwnd As
IntPtr, ByVal lpString As String) As Boolean
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Oct 23 '06 #2
be*****@gmail.c om wrote:
I'm writing because I'm having some problems with the SetWindowText api
(Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA "
(ByVal hwnd As Long, ByVal lpString As String) As Long)
Your api declaration needs to be changed as Mattias already pointed
out. For additional information see here:

http://www.pinvoke.net/default.aspx/....SetWindowText

Oct 24 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1425
by: Aaron Ackerman | last post by:
I am having very odd problems with running a very simplie n-Tier Duamish-type Win Forms app. I will often encounter problems with me having to compile each tier, starting with the Data Access Layer and working up to the UI just to get the project to run. (I am using .NET 2003 by the way). Many times I get this error: "Cannot copy assembly 'MyAssembly' to file 'MyAssemblyFile' The process cannot access the file because it is being used...
1
354
by: malcolm | last post by:
Hello, We have a small team building a project that involves some 30 or so c# assembly dlls. It is a client server application with 1 exe as the starting point. The dlls and exe are sharing an assemblyinfo file that has a strong name and version assiciated with it. We are having problems in the way we have been developing. We have made two attempts at this. Attempt 1) In our first attempt, we basically had 1 folder that
6
2649
by: clintonG | last post by:
After the last six days trying to download VS2005 Professional it seems there may be a problem with my instance of the File Transfer Manager (FTM) or somewhere in the network in between. I can't even download the measely 1.5MB GIF animator which is in the Tools folder at subscriber downloads. The FTM keeps recycling with retries until it finally times out regardless of the configuration settings. I've been talking with MSDN Customer...
8
1717
by: Michael C | last post by:
Hi all, I'm still having problems with VS.NET 2003 running on my XP machine. I finally decided I might as well uninstall completely and reinstall from scratch. But lo and behold it won't let me uninstall... It gets stuck about 2/3rds of the way through the uninstall (based on the progress bar) and hangs for a very, very long time (a few hours last time). Then it seems to give up and returns an error message stating that it cannot...
1
1888
by: hamm.charlesw | last post by:
I have a small app that filters out illegal characters typed into a CEdit by doing a GetWindowText(), followed by the filtering, followed by a SetWindowText(), all within a routine fired from an ON_EN_CHANGE message. I am developing this app on VC++ 7.1 under Win2K and it works fine. When I run the app on a WinXP box, the call to SetWindowText causes the app to exit (no messages). I also tried doing a SetSel(0, 1) followed by a...
7
7855
by: support | last post by:
Hi, I am trying to change the text of a Command button using the Windows API Function SetWindowText, which I have declared as follows: <DllImport("User32")_ Public Function SetWindowText(ByVal hWnd As IntPtr, ByVal lpString As String) As Boolean End Function
2
1715
by: abxyz | last post by:
urgent required : how to get input from edit box in vc++ using GetWindowText function
1
1714
by: FordPrefect | last post by:
I am using a 3rd party dll (not COM). One of the dll functions requires a callback function. I have used either DllImport or Declare to properly (I think) declare the function. The function requires a pointer to a function for the call back, and a pointer to a data duffer. I am using a delegate to define the callback function. The callback is triggered correctly and I am able to print the result of the callback to Debug.Write. I can...
6
2031
by: Pep | last post by:
Firstly, I'm not sure if this is the right group for this query, so please forgive me if I am wrong. My problem is that most users I distribute my software to cannot install it on their systems due to not having the correct administrator rights. I'm perplexed over this as I cannot reasonably ask corporations to allow the local secretary to have admin or power user rights just to install my software. My software is intended for user...
0
8268
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
8202
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
8707
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
8641
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8510
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
5575
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();...
0
4093
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...
0
4202
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2628
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 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.