0

遇到不同 FormBorderStyle 模式的问题。在“无”模式下,一切正常。

截图 1

但是,一旦我将模式更改为其他任何模式-就会发生这种情况:

截图 2

我周围到处都是奇怪的空白区域。就像两个轴上的界限都关闭了

void InitializeComponent(void)
{
    this->SuspendLayout();
    // 
    // MainUI
    // 
    this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::None;
    this->ClientSize = System::Drawing::Size(320, 250);
    this->FormBorderStyle = System::Windows::Forms::FormBorderStyle::FixedToolWindow;
    this->MaximizeBox = false;
    this->MinimizeBox = false;
    this->Name = L"MainUI";
    this->Text = L"Dota 2 Efficiency Application";
    this->ResumeLayout(false);
}
[STAThreadAttribute]
int Main(array<System::String ^> ^args){
Application::EnableVisualStyles();
Application::SetCompatibleTextRenderingDefault(false);

// Creating a new form
MainUI^ form = gcnew MainUI();

// Creating a new ListView and adding it to the form
createList();
form->globalTimerInit();
form->Controls->Add(myGlobals::Globals::globalListView);
form->Controls->Add(myGlobals::Globals::labelForTimer);
Application::Run(form);

return 0;
}

当我试图获取 Form 的 Bounds 和 ClientRectangle 时,它​​会吐出:

{X=0,Y=0,宽度=336,高度=284}
{X=0,Y=0,宽度=320,高度=250}

看起来它是正确的,但该区域是很远的。

有什么建议吗?

4

1 回答 1

0

我有多个 __super::WndProc(m); 实例 并导致了这种行为。

ui.h

#include "stdafx.h"
    ////////////////////////HOTKEYS////////////////////////
protected: // Function that defines a hotkey
    virtual void OnHandleCreated(EventArgs^ e) override {
        __super::OnHandleCreated(e);
        RegisterHotKey((HWND)this->Handle.ToPointer(), 1,
            MOD_NOREPEAT, (UINT)Keys::NumPad3);
        RegisterHotKey((HWND)this->Handle.ToPointer(), 2,
            MOD_NOREPEAT, (UINT)Keys::NumPad2);
        RegisterHotKey((HWND)this->Handle.ToPointer(), 3,
            MOD_NOREPEAT, (UINT)Keys::NumPad1);
        RegisterHotKey((HWND)this->Handle.ToPointer(), 4,
            MOD_NOREPEAT, (UINT)Keys::NumPad0);
    }

protected: // Function that executes code on hotkey
    virtual void WndProc(Message% m) override {
        if (m.Msg == WM_HOTKEY && m.WParam.ToInt32() == 1) {
            //roshTimer();
        }
        if (m.Msg == WM_HOTKEY && m.WParam.ToInt32() == 2) {
            //wardPurchased();
        }
        __super::WndProc(m);
        if (m.Msg == WM_HOTKEY && m.WParam.ToInt32() == 3) {
            //globalTimerStartPause();
        }
        __super::WndProc(m);
        if (m.Msg == WM_HOTKEY && m.WParam.ToInt32() == 4) {
            //reserved for future needs
        }
        __super::WndProc(m);
    }
    ///////////////////////////////////////////////////////

标准数据文件

#pragma once

#include <Windows.h>
#pragma comment(lib, "user32.lib")
于 2018-04-29T17:02:06.280 回答