Einzelnen Beitrag anzeigen

Benutzerbild von Remko
Remko

Registriert seit: 10. Okt 2006
Ort: 's-Hertogenbosch, Die Niederlande
222 Beiträge
 
RAD-Studio 2010 Arc
 
#29

Re: Convert sample from platform SDK to Delphi

  Alt 27. Dez 2006, 11:17
OK, so:
Code:
LRESULT CALLBACK CPropSheetHost::_HiddenWindowProc( HWND hWnd,
                                                    UINT uMessage,
                                                    WPARAM wParam,
                                                    LPARAM lParam)
{
    CPropSheetHost *pThis = (CPropSheetHost*)((LONG_PTR)GetWindowLongPtr(hWnd, VIEW_POINTER_OFFSET));

    switch (uMessage)
    {
    case WM_NCCREATE:
        {
            LPCREATESTRUCT lpcs = (LPCREATESTRUCT)lParam;
            pThis = (CPropSheetHost*)(lpcs->lpCreateParams);
            ::SetWindowLongPtr(hWnd, VIEW_POINTER_OFFSET, (LONG)(LONG_PTR)pThis);
        }
        break;

    case WM_CREATE:
        break;

    case WM_DESTROY:
        break;

    case WM_ADSPROP_NOTIFY_CHANGE:
        OutputDebugString(TEXT("WM_ADSPROP_NOTIFY_CHANGE\n"));
        break;

    case WM_DSA_SHEET_CREATE_NOTIFY:
        {
            PDSA_SEC_PAGE_INFO pSecPageInfo;
           
            // Extract the secondary sheet information from the wParam.
            if(S_OK == pThis->_ExtractSecPageInfo(wParam, &pSecPageInfo))
            {
                // Create a secondary property sheet.
                pThis->_CreateSecondaryPropertySheet(pSecPageInfo);
            }
            else
            {
                // Even if the extraction failed, the wParam needs to be freed.
                pSecPageInfo = (PDSA_SEC_PAGE_INFO)wParam;
            }

            /*
            The receiver of the message must free the DSA_SEC_PAGE_INFO
            structure when it is no longer needed.
            */
            LocalFree(pSecPageInfo);
        }
        return 0;

    case WM_DSA_SHEET_CLOSE_NOTIFY:
        if(PROP_SHEET_HOST_ID == wParam)
        {
            OutputDebugString(TEXT("PROP_SHEET_HOST_ID\n"));
        }
        return 0;

    default:
        break;
    }

    return DefWindowProc(hWnd, uMessage, wParam, lParam);
}
Delphi-Quellcode:
function TPropSheetHost._HiddenWindowProc(hWnd: HWnd; Msg: UINT; WParam: WPARAM; LParam: LPARAM): UINT; stdcall;
var lpcs: TCreateStruct;
  PropSheetHost: TPropSheetHost;
  pSecPageInfo: PDSA_SEC_PAGE_INFO;
  begin
  PropSheetHost := TPropSheetHost(GetWindowLong(hWnd, VIEW_POINTER_OFFSET));
  case Msg of
    WM_NCCREATE: SetWindowLong(hWnd, VIEW_POINTER_OFFSET, LONG(LPCREATESTRUCT(lParam).lpCreateParams));
    WM_CREATE:;
    WM_DESTROY:;
    WM_ADSPROP_NOTIFY_CHANGE: OutputDebugString('WM_ADSPROP_NOTIFY_CHANGE'#10#13);
    WM_DSA_SHEET_CREATE_NOTIFY:
    begin
      // Extract the secondary sheet information from the wParam.
      if _ExtractSecPageInfo(wParam, pSecPageInfo) = S_OK then
      begin
        // Create a secondary property sheet.
        _CreateSecondaryPropertySheet(pSecPageInfo);
      end
      else begin
        // Even if the extraction failed, the wParam needs to be freed.
        pSecPageInfo := PDSA_SEC_PAGE_INFO(wParam);
      end;
      {*
      The receiver of the  message must free the DSA_SEC_PAGE_INFO
      structure when it is no longer needed.
      *}

      LocalFree(Cardinal(pSecPageInfo));
      Result := 0;
      Exit;
    end;
    WM_DSA_SHEET_CLOSE_NOTIFY:
    begin
      if PROP_SHEET_HOST_ID = wParam then
      begin
        OutputDebugString('PROP_SHEET_HOST_ID'#10#13);
      end;
      Result := 0;
    end;
  end;
  Result := DefWindowProc(hWnd, Msg, wParam, lParam);
end;
  Mit Zitat antworten Zitat