15,896,912 members
Sign in
Sign in
Email
Password
Forgot your password?
Sign in with
home
articles
Browse Topics
>
Latest Articles
Top Articles
Posting/Update Guidelines
Article Help Forum
Submit an article or tip
Import GitHub Project
Import your Blog
quick answers
Q&A
Ask a Question
View Unanswered Questions
View All Questions
View C# questions
View C++ questions
View Javascript questions
View Visual Basic questions
View Python questions
discussions
forums
CodeProject.AI Server
All Message Boards...
Application Lifecycle
>
Running a Business
Sales / Marketing
Collaboration / Beta Testing
Work Issues
Design and Architecture
Artificial Intelligence
ASP.NET
JavaScript
Internet of Things
C / C++ / MFC
>
ATL / WTL / STL
Managed C++/CLI
C#
Free Tools
Objective-C and Swift
Database
Hardware & Devices
>
System Admin
Hosting and Servers
Java
Linux Programming
Python
.NET (Core and Framework)
Android
iOS
Mobile
WPF
Visual Basic
Web Development
Site Bugs / Suggestions
Spam and Abuse Watch
features
features
Competitions
News
The Insider Newsletter
The Daily Build Newsletter
Newsletter archive
Surveys
CodeProject Stuff
community
lounge
Who's Who
Most Valuable Professionals
The Lounge
The CodeProject Blog
Where I Am: Member Photos
The Insider News
The Weird & The Wonderful
help
?
What is 'CodeProject'?
General FAQ
Ask a Question
Bugs and Suggestions
Article Help Forum
About Us
Search within:
Articles
Quick Answers
Messages
Comments by Craig Haywood (Top 17 by date)
Craig Haywood
13-Oct-14 6:30am
View
Thanks BillWoodruff.
I always used
If IntPtr.Size = 8 Then
Craig Haywood
13-Oct-14 5:10am
View
I never knew you could dllimport a function with the same name twice if it has different signitures. Thanks Pikoh, I am going to accept your solution as it seems to be working in initial tests
Craig Haywood
13-Oct-14 4:53am
View
Indeed I did, but how do you declare the same function twice in the same application?
Craig Haywood
13-Oct-14 4:30am
View
Where have you found that different signatures works on different bit systems? Can you give an example
Craig Haywood
13-Oct-14 4:28am
View
Hi Mehdi,
This does not provide a solution. The first link takes me to an incomprehensible solution as I don't even know what language that is. The second link is just the msdn explanation of what the function does and the third uses the exact same declare statement I am using
Craig Haywood
7-Oct-14 12:59pm
View
I just want to say thank you to everybody who tried to help. I am not going to waste anymore time on this.
It would be nice if I can use my set topmost function as a toggle topmost on or off but unfortunately it doesn't make sense spending two days researching something I can already do with two different functions as opposed to one.
Craig Haywood
7-Oct-14 12:43pm
View
I'm starting to think this is just not possible in vb or C#
Imports System.Runtime.InteropServices
Public Class Form1
<DllImport("user32.dll", EntryPoint:="GetWindowLongPtrW")> _
Public Shared Function GetWindowLongPtrW(ByVal hWnd As HandleRef, ByVal nIndex As Integer) As IntPtr
End Function
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim notepad As Process = Process.GetProcessesByName("notepad")(0)
Dim hWnd As IntPtr = notepad.MainWindowHandle
Dim notepad2 As New HandleRef(0, hWnd)
Dim Style As IntPtr = GetWindowLongPtrW(notepad2, -20)
MsgBox(Style.ToString)
End Sub
End Class
Additional information: Unable to find an entry point named 'GetWindowLongPtrW' in DLL 'user32.dll'.
Craig Haywood
7-Oct-14 3:03am
View
GetWindowLongPtr gives a first chance exception of type 'System.EntryPointNotFoundException'
Imports System.Runtime.InteropServices
Public Class Form1
<DllImport("user32.dll")> _
Private Shared Function GetWindowLongPtr(ByVal hWnd As IntPtr, ByVal nIndex As Integer) As IntPtr
End Function
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Dim notepad As Process = Process.GetProcessesByName("notepad")(0)
Dim hWnd As IntPtr = notepad.MainWindowHandle
Dim GWL_EXSTYLE As IntPtr = -20
Dim WS_EX_TOPMOST As IntPtr = 8
Dim Style As IntPtr = GetWindowLongPtr(hWnd, GWL_EXSTYLE)
End Sub
End Class
Craig Haywood
6-Oct-14 11:04am
View
Thanks @BillWoodruff. I am searching global hooks now
Craig Haywood
6-Oct-14 10:52am
View
From everything I have read, this seems to be the approach, in my tests, GetWindowLong always returns 0. Maybe somebody here can get it to work on both 32bit and 64bit machines
Craig Haywood
6-Oct-14 10:33am
View
I am using the global hook at https://globalmousekeyhook.codeplex.com/.
As for my dilemma, from reading a lot of articles, it seems as if I need to use GetWindowLong to find the topmost state of an external app. However, from http://www.pinvoke.net it seems as if this is a mess in vb or c#, especially if used between 32bit and 64bit machines.
Anyway, I have tried it, but GetWindowLong always returns 0 for me.
Craig Haywood
6-Oct-14 7:36am
View
I am writing an application that amongst other thing will perform global mouse gestures. I want users to be able to assign their own actions to the gestures and also provide a few built in functions.
One of these functions will be to toggle an external window's topmost state. Of course I can have an action that sets the topmost state to true and another that sets it to false. It just seems ridiculous to use two different gestures to do basically the same thing.
If I can find out the topmost state of an external application, then I can use one gesture to toggle it on when it is set to false and off when it is set to true
Craig Haywood
6-Oct-14 7:30am
View
Nothing as yet as I do not know how. That's why I am asking
Craig Haywood
6-Oct-14 7:26am
View
Deleted
Dim cp As CreateParams = MyBase.CreateParams
If cp.ExStyle = CInt(HWND_TOPMOST) Then
SetWindowPos(Me.Handle(), HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE)
Else
SetWindowPos(Me.Handle(), HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE)
End If
Craig Haywood
6-Oct-14 7:21am
View
This can be any external window that is not part of my application. Whether it is winforms or wpf is irrelevant. I know how to set the topmost state of an external window as well as how to remove it, but in order to create a toggle function in my application, I first need to get the current topmost state for the external window.
Craig Haywood
5-Oct-14 4:21am
View
Read the question. I think I explained what I mean with friendly name
Craig Haywood
30-Apr-14 6:20am
View
I am actually looking for a solution on how to do this in code, not to make use of another third party program.
Show More