Skip to content

Instantly share code, notes, and snippets.

@houselet
houselet / PlayWinmainByPython.py
Created October 18, 2013 17:23
用 Python 扫雷
#-*-coding: utf8 -*-
import win32gui
import win32process
import win32con
import win32api
from ctypes import *
# 雷区最大行列数
MAX_ROWS = 24
LPCTSTR GetLastErrorMessage()
{
static TCHAR buffer[MAX_PATH+1];
DWORD errCode = GetLastError();
TCHAR *err;
if (!FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL, errCode, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // default language
(LPTSTR) &err, 0, NULL))
return _T("");
_tcsncpy (buffer, err, MAX_PATH);
@houselet
houselet / Get WM_MOUSELEAVE WM_MOUSEHOVER By WM_MOUSEMOVE.cpp
Created August 30, 2013 10:23
TrackMouseEvent replaced, implement WM_MOUSELEAVE/WM_MOUSEHOVER for wince piece of cake
LRESULT CALLBACK WindowProcXP (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
//TRACKMOUSEEVENT Tme;
static HWND hWndPrevious = NULL;
switch (uMsg)
{
case WM_MOUSEMOVE:
//
//Tme.cbSize = sizeof (TRACKMOUSEEVENT);
//Tme.dwFlags = TME_LEAVE;
/////////////////////////////////////////////////////////////////////////////
// CSeparator message handlers
// http://www.codeproject.com/Articles/77/Enhanced-Line-Drawing-Class-with-Text
// This function draws the horizontal line, followed by the text. The general
// idea for the line drawing comes from Hans Buehler's article at
// http://www.codeguru.com/staticctrl/draw_bevel.shtml
//
// Note that this class is intended to be just a simple separator, so the
// only static styles I implement here are SS_LEFT, SS_CENTER, SS_RIGHT, and
// SS_NOPREFIX. Also note that the line is always drawn vertically centered
// 摘自:Programming Windows Embedded CE 6.0 Developer Reference
// 作者:Douglas Boling
// HelloCE.cpp
// ——————————————————————————————————————
//==================================================================
// HelloCE - A simple application for Windows CE
// Written for the book Programming Windows CE
// Copyright (C) 2007 Douglas Boling
//==================================================================
#include "stdafx.h"
#include "toclip.h"
/****************************************************************
* toClipboard
* Inputs:
* CWnd * wnd: Window whose contents are to be sent
* to the clipboard
* BOOL FullWnd: TRUE for entire window,
* FALSE for client area
* Result: void
void SaveDIBitmap(CDC* dc, const CRect& rcSave, LPCSTR filename)
{
int nWidth = rcSave.Width();
int nHeight = rcSave.Height();
int nBitCount = 24;
int nWidthBytes = ((nWidth * (nBitCount>>3) + 3) >> 2) << 2;
HDC hMemDC = ::CreateCompatibleDC(dc->m_hDC);
BITMAPINFO bminfo;
void EnumerateBits(LPBYTE pBits, int nBitCount, int nWidth, int nHeight)
{
int nPixels = nWidth * nHeight;
WORD wByteCount = nBitCount / 8;
if(wByteCount == 0)
wByteCount = 1;
int nBytes = nPixels * wByteCount;
for(int i = 0; i < nBytes; i += wByteCount)
{
@houselet
houselet / Popup Window.cpp
Created August 15, 2013 04:16
create a popup window with WM_POPUPWINDOW create a bordless popup window with WM_POPUP create a popup window without focus use ShowWindow(hWnd, SW_SHOWNOACTIVATE) or SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);
#include <windows.h>
#ifdef __BORLANDC__
#pragma argsused
#endif
//---------------------------------------------------------------------------
const char *ClsName = "WndProperties";
const char *WndName = "Popup Window";
//---------------------------------------------------------------------------
LRESULT CALLBACK WndProcedure(HWND hWnd, UINT uMsg,
WPARAM wParam, LPARAM lParam);
data:text/html, <style type="text/css">#e{position:absolute;top:0;right:0;bottom:0;left:0;}</style><div id="e"></div><script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script><script>var e=ace.edit("e");e.setTheme("ace/theme/monokai");e.getSession().setMode("ace/mode/ruby");</script>