ID do artigo: 121541 - Última revisão: segunda-feira, 11 de julho de 2005 - Revisão: 1.3

Como substituir arrastar total

Dica do SistemaEste artigo aplica-se a um sistema operativo diferente do que está a utilizar. Foi desactivado o conteúdo do artigo, que pode não ser relevante para si.

Nesta página

Expandir tudo | Recolher tudo

Sumário

Windows NT versão 3.5 apresenta arrastar completo, que lhe permite ver a janela inteira movendo ou redimensionando em vez de ver apenas um contorno de janela mover ou redimensionar. O aplicativo de exemplo abaixo demonstra como habilitar arrastar completo, executando o miniaplicativo do painel de controle de área de trabalho e selecionando a caixa de seleção arrastar total.

Mais Informações

Quando você redimensiona uma janela com total arrastar habilitado, o aplicativo receberá várias mensagens indicando que a janela está redimensionando. (Você pode verificar isso com Spy.) Se isso tiver efeitos indesejáveis no seu aplicativo, você precisará substituir o recurso de arrastar completo em seu aplicativo.

Quando a movimentação ou redimensionamento for iniciado, o aplicativo recebe esta mensagem:
   WM_ENTERSIZEMOVE (0231)
				
quando termina a movimentação ou redimensionamento, o aplicativo recebe esta mensagem:
   WM_EXITSIZEMOVE (0232)
				
as mensagens acima atuam como uma notificação de que a janela está entrando e saindo uma operação de dimensionamento ou movimentação. Se desejar, você pode usar essas notificações para definir um sinalizador para impedir que o programa de tratamento de uma mensagem WM_PAINT durante a movimentação ou operação de tamanho para substituir completo arraste.

Código de exemplo

   /***********************************************************************
    *
    · Fulldrag.c
     *
    · Copyright (c) 1997 Microsoft Corporation.
     *
    · Abstract:
     *
    · Sample program that demonstrates how a program can override
    · Full Drag.
     *

   ***********************************************************************/ 

    #define STRICT
    #include <windows.h>


   /***********************************************************************
     *
    · Globals
     *
    · g_fMoveSize
     *
    · Set while you are in a move/size loop. The WM_ENTERSIZEMOVE
    · and WM_EXITSIZEMOVE messages tell you when these things happen.
     *
    · g_fPaintDeferred
     *
    · Set if you deferred a paint that occurred while you were
    · busy doing a Move/Size. When the Move/Size completes
    · and you discover that a paint was deferred, you force
    · a full repaint to complete the deferred paint.
     *
     *
    · Note:
     *
    · In a real (that is, non-sample) program, these would not be global
    · variables. They would be per-window variables.
     *

   ***********************************************************************/ 

    BOOL g_fDragging;
    BOOL g_fPaintDeferred;


   /***********************************************************************
     *
    · Hilbert
     *
    · Draws a segment of the hilbert curve.
     *
    · The math is not important. What is important is that drawing
    · a hilbert curve takes a long time.
     *

   ***********************************************************************/ 

    #define MAXDEPTH 8      /* Bigger depth takes longer to draw. */ 
    void
    Hilbert(HDC hdc, int x, int y, int vx, int vy, int wx, int wy, int n)
    {
    if (n >= MAXDEPTH) {
    LineTo(hdc, x + (vx+wx)/2, y + (vy+wy)/2);
    } else {
    n++;
    Hilbert(hdc, x, y, wx/2, wy/2, vx/2, vy/2, n);
    Hilbert(hdc, x+vx/2, y+vy/2, vx/2, vy/2, wx/2, wy/2, n);
    Hilbert(hdc, x+vx/2+wx/2, y+vy/2+wy/2, vx/2, vy/2, wx/2, wy/2, n);
    Hilbert(hdc, x+vx/2+wx, y+vy/2+wy, -wx/2, -wy/2, -vx/2, -vy/2, n);
        }
    }


   /***********************************************************************
     *
    · Hilbert_OnPaint
     *
    · Handle the WM_PAINT message.
     *
    · If the user is dragging the window, then don't do painting,
    · because that would make the dragging very jerky. Instead, just
    · remember that there was a paint message that you ignored. After
    · the size/move is complete, you will perform one big paint to do
    · the things that you ignored.
     *

   ***********************************************************************/ 

    void
    Hilbert_OnPaint(HWND hwnd)
    {
    PAINTSTRUCT ps;
    RECT rc;
    HDC hdc;

    hdc = BeginPaint(hwnd, &ps);
    if (hdc) {
    if (g_fDragging) {
    g_fPaintDeferred = TRUE;
    } else {
    HBRUSH hbrOld;
    HPEN hpenOld;
    HCURSOR hcurOld;

    hcurOld = SetCursor(LoadCursor(0, IDC_WAIT));
    hbrOld = SelectObject(hdc, GetStockObject(BLACK_BRUSH)); hpenOld =
    SelectObject(hdc, GetStockObject(BLACK_PEN));
    MoveToEx(hdc, 0, 0, 0);
    Hilbert(hdc, 0, 0, GetSystemMetrics(SM_CXFULLSCREEN), 0,
    0, GetSystemMetrics(SM_CYFULLSCREEN), 0);
    SelectObject(hdc, hpenOld);
    SelectObject(hdc, hbrOld);
    SetCursor(hcurOld);
            }
    EndPaint(hwnd, &ps);
        }
    }


   /***********************************************************************
     *
    · Hilbert_WndProc
     *
    · Window procedure.
     *

   ***********************************************************************/ 

    LRESULT CALLBACK
    Hilbert_WndProc(HWND hwnd, UINT wm, WPARAM wp, LPARAM lp)
    {
    switch (wm) {
    case WM_PAINT:
    Hilbert_OnPaint(hwnd);
    break;

    case WM_DESTROY:
    PostQuitMessage(0); break;

        /*
    · When you begin a Size/Move operation, remember that you are
    · performing a Size/Move operation so you don't paint during the
    . Size/Move.
         */ 
    case WM_ENTERSIZEMOVE:
    g_fDragging = TRUE; break;

        /*
    · When you finish a Size/Move operation, remember that you are
    · performing a Size/Move operation so you will resume painting,
    . and if there were any deferred paint messages, re-invalidate
    . yourself they will be regenerated.
         */ 
    case WM_EXITSIZEMOVE:
    g_fDragging = FALSE;
    if (g_fPaintDeferred) {
    g_fPaintDeferred = FALSE;
    InvalidateRect(hwnd, 0, TRUE);
            }
    break;

        }

    return DefWindowProc(hwnd, wm, wp, lp);
    }


   /***********************************************************************
     *
    · WinMain
     *
    · Program entry point.
     *
    · Register the class, create the window, and go into a message loop.
     *

   ***********************************************************************/ 

    int WINAPI
    WinMain(HINSTANCE hinst, HINSTANCE hinstPrev, LPSTR pszCmdLine, int
    nCmdShow)
    {
    HWND hwnd;
    MSG msg;
    WNDCLASS wc = {
    0,
    Hilbert_WndProc,
    0,
    0,
    hinst,
    LoadIcon(0, IDI_APPLICATION),
    LoadCursor(0, IDC_ARROW),
    (HBRUSH)(COLOR_WINDOW+1),
    0,
    "Hilbert"
        };

    RegisterClass(&wc);
    hwnd = CreateWindow("Hilbert", "Hilbert", WS_OVERLAPPEDWINDOW,
    CW_USEDEFAULT, CW_USEDEFAULT,
    CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, hinst, 0);
    ShowWindow(hwnd, nCmdShow);
    while (GetMessage(&msg, 0, 0, 0)) {
    TranslateMessage(&msg);
    DispatchMessage(&msg);
        }

    return 0;
    }
				

A informação contida neste artigo aplica-se a:
  • Microsoft Platform Software Development Kit-January 2000 Edition
Palavras-chave: 
kbmt kbhowto kbwndw KB121541 KbMtpt
Tradução automáticaTradução automática
IMPORTANTE: Este artigo foi traduzido por um sistema de tradução automática (também designado por Machine Translation ou MT), não tendo sido portanto traduzido ou revisto por pessoas. A Microsoft possui artigos traduzidos por aplicações (MT) e artigos traduzidos por tradutores profissionais, com o objetivo de oferecer em português a totalidade dos artigos existentes na base de dados de suporte. No entanto, a tradução automática não é sempre perfeita, podendo conter erros de vocabulário, sintaxe ou gramática. A Microsoft não é responsável por incoerências, erros ou prejuízos ocorridos em decorrência da utilização dos artigos MT por parte dos nossos clientes. A Microsoft realiza atualizações freqüentes ao software de tradução automática (MT). Obrigado.
Clique aqui para ver a versão em Inglês deste artigo: 121541  (http://support.microsoft.com/kb/121541/en-us/ )