"Fossies" - the Fresh Open Source Software Archive

Member "dmd2/src/druntime/import/core/sys/windows/dde.d" (20 Nov 2020, 7298 Bytes) of package /linux/misc/dmd.2.094.2.linux.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) D source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 /**
    2  * Windows API header module
    3  *
    4  * Translated from MinGW Windows headers
    5  *
    6  * Authors: Stewart Gordon
    7  * License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
    8  * Source: $(DRUNTIMESRC src/core/sys/windows/_dde.d)
    9  */
   10 module core.sys.windows.dde;
   11 version (Windows):
   12 @system:
   13 pragma(lib, "user32");
   14 
   15 private import core.sys.windows.windef;
   16 
   17 enum : uint {
   18     WM_DDE_FIRST     = 0x03E0,
   19     WM_DDE_INITIATE  = WM_DDE_FIRST,
   20     WM_DDE_TERMINATE,
   21     WM_DDE_ADVISE,
   22     WM_DDE_UNADVISE,
   23     WM_DDE_ACK,
   24     WM_DDE_DATA,
   25     WM_DDE_REQUEST,
   26     WM_DDE_POKE,
   27     WM_DDE_EXECUTE,
   28     WM_DDE_LAST      = WM_DDE_EXECUTE
   29 }
   30 
   31 struct DDEACK {
   32     ubyte bAppReturnCode;
   33     ubyte _bf;
   34 
   35     @property ubyte reserved() { return cast(ubyte) (_bf & 0x3F); }
   36     @property bool  fBusy()    { return cast(bool)  (_bf & 0x40); }
   37     @property bool  fAck()     { return cast(bool)  (_bf & 0x80); }
   38 
   39     @property ubyte reserved(ubyte r) {
   40         _bf = cast(ubyte) ((_bf & ~0x3F) | (r & 0x3F));
   41         return cast(ubyte)(r & 0x3F);
   42     }
   43 
   44     @property bool fBusy(bool f) { _bf = cast(ubyte) ((_bf & ~0x40) | (f << 6)); return f; }
   45     @property bool fAck(bool f)  { _bf = cast(ubyte) ((_bf & ~0x80) | (f << 7)); return f; }
   46 }
   47 
   48 struct DDEADVISE {
   49     ushort _bf;
   50     short  cfFormat;
   51 
   52     @property ushort reserved()  { return cast(ushort) (_bf & 0x3FFF); }
   53     @property bool   fDeferUpd() { return cast(bool)   (_bf & 0x4000); }
   54     @property bool   fAckReq()   { return cast(bool)   (_bf & 0x8000); }
   55 
   56     @property ushort reserved(ushort r) {
   57         _bf = cast(ushort) ((_bf & ~0x3FFF) | (r & 0x3FFF));
   58         return cast(ushort)(r & 0x3FFF);
   59     }
   60 
   61     @property bool   fDeferUpd(bool f) { _bf = cast(ushort) ((_bf & ~0x4000) | (f << 14)); return f; }
   62     @property bool   fAckReq(bool f)   { _bf = cast(ushort) ((_bf & ~0x8000) | (f << 15)); return f; }
   63 }
   64 
   65 struct DDEDATA {
   66     ushort _bf;
   67     short  cfFormat;
   68     byte   _Value;
   69 
   70     @property ushort unused()    { return cast(ushort) (_bf & 0x0FFF); }
   71     @property bool   fResponse() { return cast(bool)   (_bf & 0x1000); }
   72     @property bool   fRelease()  { return cast(bool)   (_bf & 0x2000); }
   73     @property bool   reserved()  { return cast(bool)   (_bf & 0x4000); }
   74     @property bool   fAckReq()   { return cast(bool)   (_bf & 0x8000); }
   75 
   76     @property byte*  Value() return { return &_Value; }
   77 
   78     @property ushort unused(ushort r) {
   79         _bf = cast(ushort) ((_bf & ~0x0FFF) | (r & 0x0FFF));
   80         return cast(ushort)(r & 0x0FFF);
   81     }
   82 
   83     @property bool   fResponse(bool f) { _bf = cast(ushort) ((_bf & ~0x1000) | (f << 12)); return f; }
   84     @property bool   fRelease(bool f)  { _bf = cast(ushort) ((_bf & ~0x2000) | (f << 13)); return f; }
   85     @property bool   reserved(bool f)  { _bf = cast(ushort) ((_bf & ~0x4000) | (f << 14)); return f; }
   86     @property bool   fAckReq(bool f)   { _bf = cast(ushort) ((_bf & ~0x8000) | (f << 15)); return f; }
   87 }
   88 
   89 struct DDEPOKE {
   90     ushort _bf;
   91     short  cfFormat;
   92     byte   _Value;
   93 
   94     @property ushort unused()    { return cast(ushort) (_bf & 0x1FFF); }
   95     @property bool   fRelease()  { return cast(bool)   (_bf & 0x2000); }
   96     @property ubyte  fReserved() { return cast(ubyte)  ((_bf & 0xC000) >>> 14); }
   97 
   98     @property byte*  Value() return { return &_Value; }
   99 
  100     @property ushort unused(ushort u) {
  101         _bf = cast(ushort) ((_bf & ~0x1FFF) | (u & 0x1FFF));
  102         return cast(ushort)(u & 0x1FFF);
  103     }
  104 
  105     @property bool   fRelease(bool f)   { _bf = cast(ushort) ((_bf & ~0x2000) | (f << 13)); return f; }
  106     @property ubyte  fReserved(ubyte r) { _bf = cast(ushort) ((_bf & ~0xC000) | (r << 14)); return r; }
  107 }
  108 
  109 deprecated struct DDELN {
  110     ushort _bf;
  111     short  cfFormat;
  112 
  113     @property ushort unused()    { return cast(ushort) (_bf & 0x1FFF); }
  114     @property bool   fRelease()  { return cast(bool)   (_bf & 0x2000); }
  115     @property bool   fDeferUpd() { return cast(bool)   (_bf & 0x4000); }
  116     @property bool   fAckReq()   { return cast(bool)   (_bf & 0x8000); }
  117 
  118     @property ushort unused(ushort u) {
  119         _bf = cast(ushort)((_bf & ~0x1FFF) | (u & 0x1FFF));
  120         return cast(ushort)(u & 0x1FFF);
  121     }
  122 
  123     @property bool   fRelease(bool f)  { _bf = cast(ushort) ((_bf & ~0x2000) | (f << 13)); return f; }
  124     @property bool   fDeferUpd(bool f) { _bf = cast(ushort) ((_bf & ~0x4000) | (f << 14)); return f; }
  125     @property bool   fAckReq(bool f)   { _bf = cast(ushort) ((_bf & ~0x8000) | (f << 15)); return f; }
  126 }
  127 
  128 deprecated struct DDEUP {
  129     ushort _bf;
  130     short  cfFormat;
  131     byte   _rgb;
  132 
  133     @property ushort unused()    { return cast(ushort) (_bf & 0x0FFF); }
  134     @property bool   fAck()      { return cast(bool)   (_bf & 0x1000); }
  135     @property bool   fRelease()  { return cast(bool)   (_bf & 0x2000); }
  136     @property bool   fReserved() { return cast(bool)   (_bf & 0x4000); }
  137     @property bool   fAckReq()   { return cast(bool)   (_bf & 0x8000); }
  138 
  139     @property byte*  rgb() return { return &_rgb; }
  140 
  141     @property ushort unused(ushort r) {
  142         _bf = cast(ushort) ((_bf & ~0x0FFF) | (r & 0x0FFF));
  143         return cast(ushort)(r & 0x0FFF);
  144     }
  145 
  146     @property bool   fAck(bool f)      { _bf = cast(ushort) ((_bf & ~0x1000) | (f << 12)); return f; }
  147     @property bool   fRelease(bool f)  { _bf = cast(ushort) ((_bf & ~0x2000) | (f << 13)); return f; }
  148     @property bool   fReserved(bool f) { _bf = cast(ushort) ((_bf & ~0x4000) | (f << 14)); return f; }
  149     @property bool   fAckReq(bool f)   { _bf = cast(ushort) ((_bf & ~0x8000) | (f << 15)); return f; }
  150 }
  151 
  152 extern (Windows) {
  153     BOOL DdeSetQualityOfService(HWND, const(SECURITY_QUALITY_OF_SERVICE)*,
  154       PSECURITY_QUALITY_OF_SERVICE);
  155     BOOL ImpersonateDdeClientWindow(HWND, HWND);
  156     LPARAM PackDDElParam(UINT, UINT_PTR, UINT_PTR);
  157     BOOL UnpackDDElParam(UINT, LPARAM, PUINT_PTR, PUINT_PTR);
  158     BOOL FreeDDElParam(UINT, LPARAM);
  159     LPARAM ReuseDDElParam(LPARAM, UINT, UINT, UINT_PTR, UINT_PTR);
  160 }
  161 
  162 debug (WindowsUnitTest) {
  163     unittest {
  164         DDEACK ddeack;
  165 
  166         with (ddeack) {
  167             reserved = 10;
  168             assert (_bf == 0x0A);
  169             fBusy = true;
  170             assert (_bf == 0x4A);
  171             fAck = true;
  172             assert (_bf == 0xCA);
  173 
  174             assert (reserved == 10);
  175             assert (fBusy == true);
  176             assert (fAck == true);
  177 
  178             reserved = 43;
  179             assert (_bf == 0xEB);
  180             fBusy = false;
  181             assert (_bf == 0xAB);
  182             fAck = false;
  183             assert (_bf == 0x2B);
  184 
  185             assert (reserved == 43);
  186             assert (fBusy == false);
  187             assert (fAck == false);
  188         }
  189 
  190         DDEPOKE ddepoke;
  191 
  192         with (ddepoke) {
  193             unused = 3456;
  194             assert (_bf == 0x0D80);
  195             fRelease = true;
  196             assert (_bf == 0x2D80);
  197             fReserved = 2;
  198             assert (_bf == 0xAD80);
  199 
  200             assert (unused == 3456);
  201             assert (fRelease == true);
  202             assert (fReserved == 2);
  203 
  204             unused = 2109;
  205             assert (_bf == 0xa83d);
  206             fRelease = false;
  207             assert (_bf == 0x883d);
  208             fReserved = 1;
  209             assert (_bf == 0x483d);
  210 
  211             assert (unused == 2109);
  212             assert (fRelease == false);
  213             assert (fReserved == 1);
  214         }
  215     }
  216 }