c# - .Net correspondings of WinApi TabControl styles -


within each tab, control centers icon , label, placing icon left of label. in winapi can force icon left, leaving label centered, specifying tcs_forceiconleft style. can left-align both icon , label using tcs_forcelabelleft style.

how can make same in c#? there similar question, solution not work me, despyte use edward's advice. in class derived tabcontrol (i need draggable tabs, while tab dragged alignment of label breaks since set sizemode fixed tabs same width , dragging):

[dllimport("user32.dll", entrypoint = "setwindowlong", charset = charset.auto)] protected static extern bool setwindowlong32(intptr ptr, int index, int value); [dllimport("user32.dll", entrypoint = "setwindowlongptr", charset = charset.auto)] protected static extern bool setwindowlongptr64(intptr ptr, int index, int value); [dllimport("user32.dll", entrypoint = "setwindowpos")] protected static extern intptr setwindowpos(intptr hwnd, int hwndinsertafter, int x, int y, int cx, int cy, int wflags);  private const int gwl_style = -16; private const int tcs_forcelabelleft = 0x20; protected static bool setwindowlong(intptr ptr, int index, int value) {      if (intptr.size == 4)      {          return setwindowlong32(ptr, index, value);      }      return setwindowlongptr64(ptr, index, value); } 

and in tabcontrol constructor:

setwindowlong(handle, gwl_style, tcs_forcelabelleft); var swp_framechanged = 0x20; var swp_nomove = 0x2; var swp_nosize = 0x1; var swp_nozorder = 0x4; setwindowpos(handle, 0, 0, 0, 0, 0, swp_nomove | swp_nosize | swp_nozorder | swp_framechanged); 

i'm aware it's possible use owner-drawn mode, don't know how can use system style changing necessary elements.

if want call setwindowlong, try

[dllimport("user32.dll")] static extern bool setwindowlong(intptr ptr, int index, int value); 

if targeting 32-/64-bit platforms, this answer might throw light on how invoke function properly.


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -