Skip to content

Instantly share code, notes, and snippets.

@KOZ60
KOZ60 / WindowsHookInstaller.vb
Last active May 19, 2024 20:24
WindowsHookInstaller
Imports System.ComponentModel
Imports System.Runtime.InteropServices
''' <summary>
''' Class that install hook procedures using SetWindowsHookEx
''' </summary>
<DesignerCategory("Code")>
Public MustInherit Class WindowsHookInstaller
Inherits Component
@KOZ60
KOZ60 / ChatDataGridView.cs
Created October 22, 2023 05:51
ChatDataGridView.cs
namespace AutoSizeGridDemo
{
using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Reflection;
using System.Windows.Forms;
public partial class Form2 : Form
@KOZ60
KOZ60 / GetProperties.cs
Last active October 24, 2023 16:51
GetProperties
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq.Expressions;
using System.Reflection;
class OrderPoco
{
public int OrderID { get; set; }
@KOZ60
KOZ60 / AspectForm.cs
Last active October 30, 2023 16:35
Aspect Form
using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
public partial class Form1 : Form
{
private int ncHeight;
private int ncWidth;
private int hitTest;
private double aspect = 0;
@KOZ60
KOZ60 / GraphicsWrapper.md
Created November 10, 2023 20:07
GraphicsWrapper

ビットマップから Graphics.FromImage で Grapchis オブジェクトを作成し、TextRenderer で描画すると太く見えますが、 太く見えるのはハーフトーンで描画される部分が真っ黒に塗りつぶされているためだったみたいです。 ハーフトーンの品質を上げるとキレイに見えます。

こんなクラスを作って

Imports System.Drawing
Imports System.Drawing.Text
Imports System.Runtime.InteropServices
@KOZ60
KOZ60 / LayeredWindow.md
Last active May 20, 2024 02:27
LayeredWindow

Windows 8 から子ウインドウがレイヤードウインドウになれるので、アプリケーションマニュフェストを追加して

  <!-- Windows 8 -->
  <!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />-->

のコメントアウトを解除すると、簡単に透過できます。

Imports System.Runtime.InteropServices
@KOZ60
KOZ60 / CustomTabControl.vb
Last active November 24, 2023 16:28
CustomTabControl.vb
Option Strict On
Imports System.Runtime.InteropServices
Public Class CustomTabControl
Inherits TabControl
Public Sub New()
DoubleBuffered = True
ResizeRedraw = True
SetStyle(ControlStyles.UserPaint, False)
@KOZ60
KOZ60 / VBForm.cs
Created November 30, 2023 18:18
VBForm
using System;
using System.Collections.Generic;
using System.Windows.Forms;
public class VBForm : Form
{
private readonly List<Control> tabIndexList = new List<Control>(512);
public VBForm() {
ControlAdded += ControlAddedEvent;
@KOZ60
KOZ60 / HideMainForm.md
Last active May 20, 2024 02:26
メインフォームを非表示でアプリケーションを立ち上げるには

メインフォームを非表示でアプリケーションを立ち上げるには、SetVisibleCore を オーバーライドして、初回の引数を false にします。 Load イベントが起きなくなるので、HandleCreated イベントなどで代用するといいでしょう。

public partial class MainForm : Form
{
    private bool firstTimeVisible = true;

 public MainForm() {
@KOZ60
KOZ60 / NotifyIconSample.cs
Last active May 20, 2024 02:44
NotifyIcon Sample
using System;
using System.ComponentModel;
using System.Drawing;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Windows.Forms;
public partial class Form1 : Form
{
private NotifyIcon notifyIcon;