C# と VB.NET の質問掲示板

ASP.NET、C++/CLI、Java 何でもどうぞ

ログ内検索
  • キーワードを複数指定する場合は 半角スペース で区切ってください。
  • 検索条件は、(AND)=[A かつ B] (OR)=[A または B] となっています。
  • [返信]をクリックすると返信ページへ移動します。
キーワード/ 検索条件 /
検索範囲/ 強調表示/ ON (自動リンクOFF)
結果表示件数/ 記事No検索/ ON
大文字と小文字を区別する

全過去ログを検索

<< 0 >>
■49981  Re[1]: オフセットoffset)h8/tinyマイコン完全マニュアル
□投稿者/ はつね -(2010/05/25(Tue) 22:44:41)
    No49972 (tkana3 さん) に返信
    > それらは理解できるのですが、「h8/tinyマイコン完全マニュアル」のp143のオセットはそれらと
    > 異なるため、質問させていただきました。

    出版元に質問してみるといいと思いますよ。
    作者さんに質問を取り次いでもらえるときもあるようですし。
記事No.49972 のレス /過去ログ84より / 関連記事表示
削除チェック/

■95081  PrintDialogをスクリーン中央に表示
□投稿者/ メロン -(2020/06/22(Mon) 16:36:46)

    分類:[C#] 

    PrintDialogで、
    UseEXDialog=falseの時は、スクリーンの中央付近に表示されていたが、
    UseEXDialog=trueにすると、フォーム画面の左上付近に表示されてしまう。

    x64の為、UseEXDialog=trueの状態でスクリーンの中央に表示したい。
    お知恵をいただきたいです。
親記事 /過去ログ165より / 関連記事表示
削除チェック/

■95082  Re[1]: PrintDialogをスクリーン中央に表示
□投稿者/ furu -(2020/06/22(Mon) 17:41:17)
    No95081 (メロン さん) に返信
    > PrintDialogで、
    > UseEXDialog=falseの時は、スクリーンの中央付近に表示されていたが、
    > UseEXDialog=trueにすると、フォーム画面の左上付近に表示されてしまう。

    .Net frameworkのバーションは?

    x64でUseEXDialog=trueにしなければならない不具合は
    4.0以降で解消されているようです。
記事No.95081 のレス /過去ログ165より / 関連記事表示
削除チェック/

■95095  Re[2]: PrintDialogをスクリーン中央に表示
□投稿者/ メロン -(2020/06/23(Tue) 14:12:49)
    No95082 (furu さん) に返信
    > .Net frameworkのバーションは?
    2です。

    > x64でUseEXDialog=trueにしなければならない不具合は
    > 4.0以降で解消されているようです。
    情報ありがとうございます。

    2→4へしないとだめなんですね。
記事No.95081 のレス /過去ログ165より / 関連記事表示
削除チェック/

■95088  Re[1]: PrintDialogをスクリーン中央に表示
□投稿者/ KOZ -(2020/06/23(Tue) 09:22:17)
    No95081 (メロン さん) に返信
    > x64の為、UseEXDialog=trueの状態でスクリーンの中央に表示したい。
    
    こんな感じでどうでしょう。
    
    using System;
    using System.Drawing;
    using System.Runtime.InteropServices;
    using System.Windows.Forms;
    
    namespace DlgTest
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                using (var dlg = new PrintDialog())
                {
                    currentScreen = Screen.FromControl(this);
                    hookHandle = NativeMethods.SetWindowsHookEx(new NativeMethods.HOOKPROC(HookProc));
                    dlg.UseEXDialog = true;
                    dlg.ShowDialog();
                }
            }
    
            static Screen currentScreen;
            static IntPtr hookHandle;
    
            private static IntPtr HookProc(int nCode, IntPtr wParam, IntPtr lParam)
            {
                if (nCode == NativeMethods.HCBT_ACTIVATE)
                {
                    var scrRect = currentScreen.Bounds;
                    var dlgRect = NativeMethods.GetWindowRectangle(wParam);
                    var x = scrRect.Left + (scrRect.Width - dlgRect.Width) / 2;
                    var y = scrRect.Top + (scrRect.Height - dlgRect.Height) / 2;
                    NativeMethods.SetWindowPos(wParam, x, y);
                    NativeMethods.UnhookWindowsHookEx(hookHandle);
                }
                return NativeMethods.CallNextHookEx(hookHandle, nCode, wParam, lParam);
            }
    
            static class NativeMethods
            {
                const int WH_CBT = 5;
                const int SWP_NOSIZE = 0x0001;
                const int SWP_NOZORDER = 0x0004;
                const int SWP_NOACTIVATE = 0x0010;
                public const int HCBT_ACTIVATE = 5;
    
                public struct RECT
                {
                    public int Left, Top, Right, Bottom;
                }
    
                [DllImport("kernel32.dll")]
                public static extern int GetCurrentThreadId();
                
                public delegate IntPtr HOOKPROC(int nCode, IntPtr wParam, IntPtr lParam);
    
                [DllImport("user32.dll")]
                static extern IntPtr SetWindowsHookEx(int idHook, HOOKPROC lpfn, IntPtr hInstance, int threadId);
    
                [DllImport("user32.dll")]
                static extern bool SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int x, int y, int cx, int cy, int uFlags);
    
                [DllImport("user32.dll")]
                public static extern bool UnhookWindowsHookEx(IntPtr hHook);
    
                [DllImport("user32.dll")]
                public static extern IntPtr CallNextHookEx(IntPtr hHook, int nCode, IntPtr wParam, IntPtr lParam);
    
                [DllImport("user32.dll")]
                static extern bool GetWindowRect(IntPtr hWnd, out RECT lpRect);
    
                public static IntPtr SetWindowsHookEx(HOOKPROC lpfn)
                {
                    return SetWindowsHookEx(WH_CBT, lpfn, IntPtr.Zero, GetCurrentThreadId());
                }
    
                public static Rectangle GetWindowRectangle(IntPtr hWnd)
                {
                    var rc = new RECT();
                    GetWindowRect(hWnd, out rc);
                    return Rectangle.FromLTRB(rc.Left, rc.Top, rc.Right, rc.Bottom);
                }
    
                public static bool SetWindowPos(IntPtr hWnd, int x, int y)
                {
                    return SetWindowPos(hWnd, 0, x, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);
                }
            }
        }
    }
    
記事No.95081 のレス /過去ログ165より / 関連記事表示
削除チェック/

■95096  Re[2]: PrintDialogをスクリーン中央に表示
□投稿者/ メロン -(2020/06/23(Tue) 14:15:26)
    No95088 (KOZ さん) に返信
    ソースコードを書いていただき、ありがとうございます。
    試してみたいと思います。
記事No.95081 のレス /過去ログ165より / 関連記事表示
削除チェック/

■95099  Re[3]: PrintDialogをスクリーン中央に表示
□投稿者/ メロン -(2020/06/23(Tue) 15:03:26)
    furu さん
    KOZ さん

    どちらの方法でも、中央表示できました。
    ありがとうございました。

記事No.95081 のレス /過去ログ165より / 関連記事表示
削除チェック/

■95150  Re[4]: PrintDialogをスクリーン中央に表示
□投稿者/ メロン -(2020/06/25(Thu) 15:35:55)
    解決済みにチェック
記事No.95081 のレス / END /過去ログ165より / 関連記事表示
削除チェック/



<< 0 >>

パスワード/

- Child Tree -