Click here to Skip to main content
15,886,919 members
Home / Discussions / C#
   

C#

 
GeneralRe: Justify alignment in c# ritchtextbox control!!! Pin
hassan azizi29-Apr-04 12:24
hassan azizi29-Apr-04 12:24 
GeneralRe: Justify alignment in c# ritchtextbox control!!! Pin
Heath Stewart29-Apr-04 14:08
protectorHeath Stewart29-Apr-04 14:08 
GeneralRe: Justify alignment in c# ritchtextbox control!!! Pin
hassan azizi1-May-04 7:49
hassan azizi1-May-04 7:49 
GeneralRe: Justify alignment in c# ritchtextbox control!!! Pin
Heath Stewart1-May-04 9:05
protectorHeath Stewart1-May-04 9:05 
GeneralRe: Justify alignment in c# ritchtextbox control!!! Pin
hassan azizi1-May-04 14:19
hassan azizi1-May-04 14:19 
GeneralRe: Justify alignment in c# ritchtextbox control!!! Pin
Heath Stewart1-May-04 14:23
protectorHeath Stewart1-May-04 14:23 
GeneralRe: Justify alignment in c# ritchtextbox control!!! Pin
hassan azizi1-May-04 14:57
hassan azizi1-May-04 14:57 
GeneralRe: Justify alignment in c# ritchtextbox control!!! Pin
Heath Stewart2-May-04 5:55
protectorHeath Stewart2-May-04 5:55 
Do you know anything about native and managed data types? Your structure is completely wrong, thus it's not being marshalled correctly which explains why you're not seeing anything change. A LONG in C is not a Int64 (or long alias, which is recommended for readibility) but instead a Int32 (or int).

The structure should be defined like this:
[StructLayout(LayoutKind.Sequential)]
public struct ParaFormat2
{
  [MarshalAs(UnmanagedType.SysUInt)] public IntPtr cbSize;
  [MarshalAs(UnmanagedType.U4)] public int dwMask;
  [MarshalAs(UnmanagedType.U2)] public short wNumbering;
  [MarshalAs(UnmanagedType.U2)] public short wEffects;
  public int dxStartIndent; // A LONG is a 32-bit signed integer!
  public int dxRightIndent;
  public int dxOffset;
  [MarshalAs(UnmanagedType.U2)] public short wAlignment;
  public short cTagCount;
  [MarshalAs(UnmanagedType.ByValArray, SizeConst=32)] public int[] rgxTabs;
  public int dySpaceBefore;
  public int dySpaceAfter;
  public int dylineSpacing;
  public short sStyle;
  public byte blineSpacingRule;
  public byte bOutlineLevel;
  [MarshalAs(UnmanagedType.U2)] public short wShadingWeight;
  [MarshalAs(UnmanagedType.U2)] public short wShadingStyle;
  [MarshalAs(UnmanagedType.U2)] public short wNumberingStart;
  [MarshalAs(UnmanagedType.U2)] public short wNumberingStyle;
  [MarshalAs(UnmanagedType.U2)] public short wNumberingTab;
  [MarshalAs(UnmanagedType.U2)] public short wBorderSpace;
  [MarshalAs(UnmanagedType.U2)] public short wBorderWidth;
  [MarshalAs(UnmanagedType.U2)] public short wBorders;
}
The cbSize is defined as an IntPtr and marshalled as UnmanagedType.SysUInt because a UINT is defined as an unsigned int, where int is a platform-specific type. For 32-bit OSes, it's 32 bits. For 64-bit OSes, it's 64 bits. The OS, of course, is dependent on the bit-width of the processor.

To create the struct you need, do something like this:
ParaFormat2 format = new ParaFormat2();
format = new IntPtr(Marshal.SizeOf(typeof(ParaFormat2)));
format.dwMask = 8; // PFM_ALIGNMENT mask
format.wAlignment = 4; // PFA_JUSTIFY
SendMessage(richTextBox1.Handle, 1095, 0, ref format);


 

Microsoft MVP, Visual C#
My Articles
GeneralRe: Justify alignment in c# ritchtextbox control!!! Pin
hassan azizi2-May-04 9:18
hassan azizi2-May-04 9:18 
GeneralRe: Justify alignment in c# ritchtextbox control!!! Pin
Heath Stewart2-May-04 10:09
protectorHeath Stewart2-May-04 10:09 
GeneralRe: Justify alignment in c# ritchtextbox control!!! Pin
ZyX3-Aug-10 3:32
ZyX3-Aug-10 3:32 
Questionis there any free rtf parser component? Pin
hassan azizi28-Apr-04 22:39
hassan azizi28-Apr-04 22:39 
AnswerRe: is there any free rtf parser component? Pin
Heath Stewart29-Apr-04 3:48
protectorHeath Stewart29-Apr-04 3:48 
GeneralRe: is there any free rtf parser component? Pin
hassan azizi29-Apr-04 12:21
hassan azizi29-Apr-04 12:21 
AnswerRe: is there any free rtf parser component? Pin
Anonymous29-Apr-04 4:51
Anonymous29-Apr-04 4:51 
Questionwhy does this not work? Pin
robmays28-Apr-04 22:19
robmays28-Apr-04 22:19 
AnswerRe: why does this not work? Pin
Corinna John28-Apr-04 22:31
Corinna John28-Apr-04 22:31 
GeneralRe: why does this not work? Pin
robmays28-Apr-04 22:36
robmays28-Apr-04 22:36 
GeneralRe: why does this not work? Pin
robmays28-Apr-04 22:44
robmays28-Apr-04 22:44 
Questionhow can i create a new bitmap file? Pin
lowiq28-Apr-04 20:35
lowiq28-Apr-04 20:35 
AnswerRe: how can i create a new bitmap file? Pin
CWIZO28-Apr-04 20:58
CWIZO28-Apr-04 20:58 
GeneralRe: how can i create a new bitmap file? Pin
lowiq29-Apr-04 3:42
lowiq29-Apr-04 3:42 
AnswerRe: how can i create a new bitmap file? Pin
Heath Stewart29-Apr-04 3:44
protectorHeath Stewart29-Apr-04 3:44 
GeneralPerformance Issues Pin
Member 105947128-Apr-04 19:59
Member 105947128-Apr-04 19:59 
GeneralRe: Performance Issues Pin
Meysam Mahfouzi28-Apr-04 20:39
Meysam Mahfouzi28-Apr-04 20:39 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.