用SDK创建一个简单的窗口

本文介绍了一个在Windows CE环境下不使用MFC框架创建简单窗口程序的方法。该程序仅包含基本的消息循环,通过两个源文件实现:HelloWindow.h 和 HelloWindow.cpp。文章详细展示了窗口注册、创建及消息处理的过程。

//=====================================================================================================
//TITLE:
//  用SDK创建一个简单的窗口
//AUTHOR:
//  norains
//DATE:
//  Friday 7-April-2006
//=====================================================================================================
  在EVC编译环境下,不使用MFC框架创建一个极其简单的窗口----甚至连关闭按钮都没有,只有最简单的消息循环.
  此代码分为两个文件,分别是:HelloWindow.h和HelloWindow.cpp;代码根据《WindowCE程序设计》一书的第一个代码例子进行精简。
  
  
/*-----------------HelloWindow.h----------------------*/
//----------------------------------------------------------------------
// Function prototypes

// Returns number of elements
int InitApp (HINSTANCE);
HWND InitInstance (HINSTANCE, LPWSTR, int);
int TermInstance (HINSTANCE, int);

// Window procedures
LRESULT CALLBACK MainWndProc (HWND, UINT, WPARAM, LPARAM);

// Message handlers
LRESULT DoDestroyMain (HWND, UINT, WPARAM, LPARAM);

 


/*---------------HelloWindow.cpp----------------------*/
#include "stdafx.h"
#include "HelloWindow.h"
//----------------------------------------------------------------------
// Global data
//
const TCHAR szAppName[] = TEXT ("HelloCE");
HINSTANCE hInst;                     // Program instance handle

int WINAPI WinMain( HINSTANCE hInstance,
     HINSTANCE hPrevInstance,
     LPTSTR    lpCmdLine,
     int       nCmdShow)
{
  // TODO: Place code here.
 
  MSG msg;
    int rc = 0;
    HWND hwndMain;

    // init application
    rc = InitApp (hInstance);
    if (rc) return rc;

    // Initialize this instance.
    hwndMain = InitInstance (hInstance, lpCmdLine, nCmdShow);
    if (hwndMain == 0)
        return 0x10;

    // Application message loop
    while (GetMessage (&msg, NULL, 0, 0)) {
        TranslateMessage (&msg);
        DispatchMessage (&msg);
    }
    // Instance cleanup
    return TermInstance (hInstance, msg.wParam);

 return 0;
}

//----------------------------------------------------------------------
// InitApp - Application initialization
//
int InitApp (HINSTANCE hInstance) {
    WNDCLASS wc;

    // Register application main window class.
    wc.style = 0;                             // Window style
    wc.lpfnWndProc = MainWndProc;             // Callback function
    wc.cbClsExtra = 0;                        // Extra class data
    wc.cbWndExtra = 0;                        // Extra window data
    wc.hInstance = hInstance;                 // Owner handle
    wc.hIcon = NULL,                          // Application icon
    wc.hCursor = NULL;                        // Default cursor
    wc.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH);
    wc.lpszMenuName =  NULL;                  // Menu name
    wc.lpszClassName = szAppName;             // Window class name

    if (RegisterClass (&wc) == 0) return 1;

    return 0;
}

//----------------------------------------------------------------------
// InitInstance - Instance initialization
//
HWND InitInstance (HINSTANCE hInstance, LPWSTR lpCmdLine,
                   int nCmdShow) {
    HWND hWnd;

    // Save program instance handle in global variable.
    hInst = hInstance;

    // Create main window.
    hWnd = CreateWindow (szAppName,           // Window class
                         TEXT("Hello"),       // Window title
                         WS_VISIBLE,          // Style flags
                         CW_USEDEFAULT,       // x position
                         CW_USEDEFAULT,       // y position
                         CW_USEDEFAULT,      // Initial width
                         CW_USEDEFAULT,      // Initial height
                         NULL,                // Parent
                         NULL,                // Menu, must be null
                         hInstance,           // Application instance
                         NULL);               // Pointer to create parameters
                        
     /*----------------------------------------------------------------------------------------------------
     //------If you want the window not to display in the taskbar,you should use the following code.------//
      hWnd=CreateWindowEx(WS_EX_TOOLWINDOW|WS_EX_NOACTIVATE, // Window type
                     szAppName,      // Window class
                     TEXT("Hello"),    // Window title
                     WS_POPUP,       // Style flags
                     CW_USEDEFAULT,    // x position
                     CW_USEDEFAULT,    // y position
                     CW_USEDEFAULT,    // Initial width
                     CW_USEDEFAULT,    // Initial height
                     NULL,        // Parent
                     NULL,        // Menu, must be null
                     hInstance,      // Application instance
                     NULL         // Pointer to create parameters
                     );
    
     -----------------------------------------------------------------------------------------------------*/

    // Return fail code if window not created.
    if (!IsWindow (hWnd)) return 0;

    // Standard show and update calls
    ShowWindow (hWnd, nCmdShow);
    UpdateWindow (hWnd);
    return hWnd;
}

//----------------------------------------------------------------------
// TermInstance - Program cleanup
//
int TermInstance (HINSTANCE hInstance, int nDefRC) {

    return nDefRC;
}

//----------------------------------------------------------------------
// MainWndProc - Callback function for application window
//
LRESULT CALLBACK MainWndProc (HWND hWnd, UINT wMsg, WPARAM wParam,
                              LPARAM lParam)
{
   
    // Search message list to see if we need to handle this
    // message.  If in list, call procedure.
  switch(wMsg)
  {
 case WM_DESTROY:
  return DoDestroyMain(hWnd,wMsg,wParam,lParam);
 default:
  return DefWindowProc (hWnd, wMsg, wParam, lParam);
  }
}

//----------------------------------------------------------------------
// DoDestroyMain - Process WM_DESTROY message for window.
//
LRESULT DoDestroyMain (HWND hWnd, UINT wMsg, WPARAM wParam,
                       LPARAM lParam) {
    PostQuitMessage (0);
    return 0;
}

源码来自:https://pan.quark.cn/s/41b9d28f0d6d 在信息技术领域中,jQuery作为一个广受欢迎的JavaScript框架,显著简化了诸多操作,包括对HTML文档的遍历、事件的管理、动画的设计以及Ajax通信等。 本篇文档将深入阐释如何运用jQuery达成一个图片自动播放的功能,这种效果常用于网站的轮播展示或幻灯片演示,有助于优化用户与页面的互动,使网页呈现更加动态的视觉体验。 为了有效实施这一功能,首先需掌握jQuery的核心操作。 通过$符号作为接口,jQuery能够迅速选取DOM组件,例如$("#id")用于选取具有特定ID的元素,而$(".class")则能选取所有应用了某类class的元素。 在选定元素之后,可以执行多种行为,诸如事件监听、样式的变更、内容的更新以及动画的制作等。 关于“一个基于jQuery的图片自动播放功能”,首要任务是准备一组图片素材,这些素材将被整合至一个容器元素之中。 例如,可以构建一个div元素,将其宽度设定为单张图片的尺寸,再借助CSS实现溢出内容的隐藏,从而构建出水平滚动的初始框架。 ```html<div id="slider"> <img src="image1.jpg" alt="Image 1"> <img src="image2.jpg" alt="Image 2"> <!-- 更多图片内容... --></div>```接着,需要编写jQuery脚本以实现图片的自动切换。 这通常涉及到定时器的运用,以设定周期性间隔自动更换当前显示的图片。 通过使用`.fadeOut()`和`.fadeIn()`方法,能够实现图片间的平滑过渡,增强视觉效果。 ```javascript$(document).re...
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值