Using CreateWindowEx to create a borderless window of absolute size Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30 pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Create ArrayList from arrayHow do I create a Java string from the contents of a file?How can I create an executable JAR with dependencies using Maven?Is there a way to detect if a browser window is not currently active?How do I create a file and write to it in Java?Creating a memory leak with JavaHow to get window proc parameters?Open link in new tab or windowSwitching JPanelsWinAPI - Determine if a window has maximize/restore capability
Retract an already submitted Recommendation Letter (written for an undergrad student)
What to do with someone that cheated their way though university and a PhD program?
How to compute a Jacobian using polar coordinates?
What is the purpose of the side handle on a hand ("eggbeater") drill?
How would it unbalance gameplay to rule that Weapon Master allows for picking a fighting style?
What were wait-states, and why was it only an issue for PCs?
Why I cannot instantiate a class whose constructor is private in a friend class?
Is it OK if I do not take the receipt in Germany?
Married in secret, can marital status in passport be changed at a later date?
Marquee sign letters
Could a cockatrice have parasitic embryos?
Is Bran literally the world's memory?
Is a self contained air-bullet cartridge feasible?
Is there an efficient way for synchronising audio events real-time with LEDs using an MCU?
Bright yellow or light yellow?
Preserving file and folder permissions with rsync
Was Objective-C really a hindrance to Apple software development?
What happened to Viserion in Season 7?
What is /etc/mtab in Linux?
Processing ADC conversion result: DMA vs Processor Registers
What *exactly* is electrical current, voltage, and resistance?
Test if all elements of a Foldable are the same
How to begin with a paragraph in latex
How was Lagrange appointed professor of mathematics so early?
Using CreateWindowEx to create a borderless window of absolute size
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30 pm US/Eastern)
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!Create ArrayList from arrayHow do I create a Java string from the contents of a file?How can I create an executable JAR with dependencies using Maven?Is there a way to detect if a browser window is not currently active?How do I create a file and write to it in Java?Creating a memory leak with JavaHow to get window proc parameters?Open link in new tab or windowSwitching JPanelsWinAPI - Determine if a window has maximize/restore capability
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I'm trying to use purely JNA to create a borderless window and also control its size. I can create the window using this:
String windowClass = new String("NewWindowClass");
HMODULE hInst = Kernel32.INSTANCE.GetModuleHandle("");
WNDCLASSEX wClass = new WNDCLASSEX();
wClass.hInstance = hInst;
wClass.lpfnWndProc = Main.this;
wClass.lpszClassName = windowClass;
User32.INSTANCE.RegisterClassEx(wClass);
HWND hWnd = User32.INSTANCE.CreateWindowEx(User32.WS_EX_TOPMOST, windowClass, "This is the window title", 0, 0, 0, 50, 50, null, null, hInst, null);
User32.INSTANCE.ShowWindow(hWnd, 1);
The 50, 50
being the width and height of the window. This was sourced from some JNA demo code (lines 54-74). I can remove the borders by adding this code after it:
long style = User32.INSTANCE.GetWindowLong(hWnd, User32.GWL_STYLE);
style &= (~User32.WS_CAPTION);
User32.INSTANCE.SetWindowLong(hWnd, User32.GWL_STYLE, (int) style);
So now you can see that there's an un-decorated window, however unlike the expected 50x50 dimensions, the size still seems to be affected by the caption bar and border but I just don't know how to stop it. I tried a bunch of windows styles and extended window styles with no luck.
Just to be sure I could get it the way I wanted, I created a simple JFrame:
JFrame frame = new JFrame("Title");
frame.setUndecorated(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(50, 50);
frame.setVisible(true);
Using Microsoft Spy++, I cross referenced the window styles to make sure they matched and even with the same styles, I just couldn't get it to change to the size I want it. So I'm guessing this isn't something to do with the window styles but I don't know where to go from here. Anyone have any info on this?
Thanks in advance.
java winapi window jna
add a comment |
I'm trying to use purely JNA to create a borderless window and also control its size. I can create the window using this:
String windowClass = new String("NewWindowClass");
HMODULE hInst = Kernel32.INSTANCE.GetModuleHandle("");
WNDCLASSEX wClass = new WNDCLASSEX();
wClass.hInstance = hInst;
wClass.lpfnWndProc = Main.this;
wClass.lpszClassName = windowClass;
User32.INSTANCE.RegisterClassEx(wClass);
HWND hWnd = User32.INSTANCE.CreateWindowEx(User32.WS_EX_TOPMOST, windowClass, "This is the window title", 0, 0, 0, 50, 50, null, null, hInst, null);
User32.INSTANCE.ShowWindow(hWnd, 1);
The 50, 50
being the width and height of the window. This was sourced from some JNA demo code (lines 54-74). I can remove the borders by adding this code after it:
long style = User32.INSTANCE.GetWindowLong(hWnd, User32.GWL_STYLE);
style &= (~User32.WS_CAPTION);
User32.INSTANCE.SetWindowLong(hWnd, User32.GWL_STYLE, (int) style);
So now you can see that there's an un-decorated window, however unlike the expected 50x50 dimensions, the size still seems to be affected by the caption bar and border but I just don't know how to stop it. I tried a bunch of windows styles and extended window styles with no luck.
Just to be sure I could get it the way I wanted, I created a simple JFrame:
JFrame frame = new JFrame("Title");
frame.setUndecorated(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(50, 50);
frame.setVisible(true);
Using Microsoft Spy++, I cross referenced the window styles to make sure they matched and even with the same styles, I just couldn't get it to change to the size I want it. So I'm guessing this isn't something to do with the window styles but I don't know where to go from here. Anyone have any info on this?
Thanks in advance.
java winapi window jna
Maybe a little early to bump, but I'm desperate :/
– Jordan
Mar 9 at 18:17
1
I'll create a native C++ example for comparison tomorrow. We'll find out what's wrong.
– LppEdd
Mar 9 at 23:24
Instead of messing with window styles, wouldn't it be easier to create borderless window from start?CreateWindowEx(User32.WS_EX_TOPMOST, windowClass, "This is the window title", User32.WS_POPUP, ...
– Daniel Sęk
Mar 10 at 14:20
add a comment |
I'm trying to use purely JNA to create a borderless window and also control its size. I can create the window using this:
String windowClass = new String("NewWindowClass");
HMODULE hInst = Kernel32.INSTANCE.GetModuleHandle("");
WNDCLASSEX wClass = new WNDCLASSEX();
wClass.hInstance = hInst;
wClass.lpfnWndProc = Main.this;
wClass.lpszClassName = windowClass;
User32.INSTANCE.RegisterClassEx(wClass);
HWND hWnd = User32.INSTANCE.CreateWindowEx(User32.WS_EX_TOPMOST, windowClass, "This is the window title", 0, 0, 0, 50, 50, null, null, hInst, null);
User32.INSTANCE.ShowWindow(hWnd, 1);
The 50, 50
being the width and height of the window. This was sourced from some JNA demo code (lines 54-74). I can remove the borders by adding this code after it:
long style = User32.INSTANCE.GetWindowLong(hWnd, User32.GWL_STYLE);
style &= (~User32.WS_CAPTION);
User32.INSTANCE.SetWindowLong(hWnd, User32.GWL_STYLE, (int) style);
So now you can see that there's an un-decorated window, however unlike the expected 50x50 dimensions, the size still seems to be affected by the caption bar and border but I just don't know how to stop it. I tried a bunch of windows styles and extended window styles with no luck.
Just to be sure I could get it the way I wanted, I created a simple JFrame:
JFrame frame = new JFrame("Title");
frame.setUndecorated(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(50, 50);
frame.setVisible(true);
Using Microsoft Spy++, I cross referenced the window styles to make sure they matched and even with the same styles, I just couldn't get it to change to the size I want it. So I'm guessing this isn't something to do with the window styles but I don't know where to go from here. Anyone have any info on this?
Thanks in advance.
java winapi window jna
I'm trying to use purely JNA to create a borderless window and also control its size. I can create the window using this:
String windowClass = new String("NewWindowClass");
HMODULE hInst = Kernel32.INSTANCE.GetModuleHandle("");
WNDCLASSEX wClass = new WNDCLASSEX();
wClass.hInstance = hInst;
wClass.lpfnWndProc = Main.this;
wClass.lpszClassName = windowClass;
User32.INSTANCE.RegisterClassEx(wClass);
HWND hWnd = User32.INSTANCE.CreateWindowEx(User32.WS_EX_TOPMOST, windowClass, "This is the window title", 0, 0, 0, 50, 50, null, null, hInst, null);
User32.INSTANCE.ShowWindow(hWnd, 1);
The 50, 50
being the width and height of the window. This was sourced from some JNA demo code (lines 54-74). I can remove the borders by adding this code after it:
long style = User32.INSTANCE.GetWindowLong(hWnd, User32.GWL_STYLE);
style &= (~User32.WS_CAPTION);
User32.INSTANCE.SetWindowLong(hWnd, User32.GWL_STYLE, (int) style);
So now you can see that there's an un-decorated window, however unlike the expected 50x50 dimensions, the size still seems to be affected by the caption bar and border but I just don't know how to stop it. I tried a bunch of windows styles and extended window styles with no luck.
Just to be sure I could get it the way I wanted, I created a simple JFrame:
JFrame frame = new JFrame("Title");
frame.setUndecorated(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(50, 50);
frame.setVisible(true);
Using Microsoft Spy++, I cross referenced the window styles to make sure they matched and even with the same styles, I just couldn't get it to change to the size I want it. So I'm guessing this isn't something to do with the window styles but I don't know where to go from here. Anyone have any info on this?
Thanks in advance.
java winapi window jna
java winapi window jna
edited Mar 9 at 23:19
cubrr
4,06121940
4,06121940
asked Mar 9 at 4:45
JordanJordan
223112
223112
Maybe a little early to bump, but I'm desperate :/
– Jordan
Mar 9 at 18:17
1
I'll create a native C++ example for comparison tomorrow. We'll find out what's wrong.
– LppEdd
Mar 9 at 23:24
Instead of messing with window styles, wouldn't it be easier to create borderless window from start?CreateWindowEx(User32.WS_EX_TOPMOST, windowClass, "This is the window title", User32.WS_POPUP, ...
– Daniel Sęk
Mar 10 at 14:20
add a comment |
Maybe a little early to bump, but I'm desperate :/
– Jordan
Mar 9 at 18:17
1
I'll create a native C++ example for comparison tomorrow. We'll find out what's wrong.
– LppEdd
Mar 9 at 23:24
Instead of messing with window styles, wouldn't it be easier to create borderless window from start?CreateWindowEx(User32.WS_EX_TOPMOST, windowClass, "This is the window title", User32.WS_POPUP, ...
– Daniel Sęk
Mar 10 at 14:20
Maybe a little early to bump, but I'm desperate :/
– Jordan
Mar 9 at 18:17
Maybe a little early to bump, but I'm desperate :/
– Jordan
Mar 9 at 18:17
1
1
I'll create a native C++ example for comparison tomorrow. We'll find out what's wrong.
– LppEdd
Mar 9 at 23:24
I'll create a native C++ example for comparison tomorrow. We'll find out what's wrong.
– LppEdd
Mar 9 at 23:24
Instead of messing with window styles, wouldn't it be easier to create borderless window from start?
CreateWindowEx(User32.WS_EX_TOPMOST, windowClass, "This is the window title", User32.WS_POPUP, ...
– Daniel Sęk
Mar 10 at 14:20
Instead of messing with window styles, wouldn't it be easier to create borderless window from start?
CreateWindowEx(User32.WS_EX_TOPMOST, windowClass, "This is the window title", User32.WS_POPUP, ...
– Daniel Sęk
Mar 10 at 14:20
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55074068%2fusing-createwindowex-to-create-a-borderless-window-of-absolute-size%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55074068%2fusing-createwindowex-to-create-a-borderless-window-of-absolute-size%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Maybe a little early to bump, but I'm desperate :/
– Jordan
Mar 9 at 18:17
1
I'll create a native C++ example for comparison tomorrow. We'll find out what's wrong.
– LppEdd
Mar 9 at 23:24
Instead of messing with window styles, wouldn't it be easier to create borderless window from start?
CreateWindowEx(User32.WS_EX_TOPMOST, windowClass, "This is the window title", User32.WS_POPUP, ...
– Daniel Sęk
Mar 10 at 14:20