|
Easy done - I try not to use arrays any more.
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
Ashfield wrote: I try not to use arrays any more
You use more expensive arrays then, there is at least one in almost every .NET collection class. Hidden, more expensive, redimming itself as required, and more comfortable.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
True enough, but easier on the typing finger
Bob
Ashfield Consultants Ltd
Proud to be a 2009 Code Project MVP
|
|
|
|
|
Hi to all,
I am facing this problem ....I have put a shock wave object on a form. When i run it, it runs fine....
Then i made a set up file. when i installed it in other machine its not running....
Wat are the necessary staff i need to do? May be some installation on the machine which i have installed the project?
It would be great, if i don't have to rebuild the project and install it again....
Please help me
-----------------------------
I am a beginner
|
|
|
|
|
Install Shockwave on the target machine.
|
|
|
|
|
thanks for the reply......But i am little confused Sir
Do you mean installing Shockwave player?....or something related to dll
-----------------------------
I am a beginner
|
|
|
|
|
Yes, the Shockware Player. It's supplying the COM library your code is using.
|
|
|
|
|
i installed it, but still its not playing the video....but the sound is playing....please help me out
-----------------------------
I am a beginner
|
|
|
|
|
I have no idea what's wrong and no way to try and replicate the problem.
|
|
|
|
|
Hi all
I m facing a problem with creating Instance of Categories Interface.
I copy this code from MSDN and try to execute in vb.net application.
Dim instance As _Categories
Dim Name As String
Dim Color As Object
Dim ShortcutKey As Object
Dim returnValue As Category
returnValue = instance.Add(Name, Color, ShortcutKey)
But it is showing Error "Object reference not set to an instance of an object."
Here is the link of msdn. Can anyone solve this problem and give me suggestion with the help of code...
http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook._categories.add.aspx[^]
Plz help it's urgent.
Regards
DC
|
|
|
|
|
I'm guessing that you are getting this error because you have declared the variables Color and ShortcutKey but not instantiated them.
|
|
|
|
|
Thanks for quick response Liqz.
Can u give me sample source code.
my code is below
Dim category_Color_Obj As Outlook.OlCategoryColor = OlCategoryColor.olCategoryColorDarkGreen
Dim category_Key_Obj As Outlook.OlCategoryShortcutKey = OlCategoryShortcutKey.olCategoryShortcutKeyNone
Dim Name As String = "DC Category"
Dim Color As Object = category_Color_Obj
Dim ShortcutKey As Object = category_Key_Obj
Dim returnValue As Category
Try
Dim instance As Categories
returnValue = instance.Add(Name, Color, ShortcutKey)
catch
msgbox "error..."
endtry
Here returnValue is showing with green line. so error is comming.
regard
dc
|
|
|
|
|
I can't give you sample code as I have never done what you are doing before. But looking at your code it looks OK to me apart from where, again, you declare a variable called 'instance' of type 'Categories' but you don't actually create an object of type 'Categories'. If the 'Add' method is an instance method rather than a class or shared method then you must create an instance of that object. Try using the 'New' keyword.
If you still get an error then post it here.
|
|
|
|
|
Categories is an interface, not a class according to MSDN example.
so we can't use new keyword. If i use new keyword then it is showing blue line in returnValue obj.
plz try this example and solve it. It's very urgent.
What is my task, I want to add new contact in outlook with category wise.
i want to add contact with color symbol as we do in outlook 2007 by category color.
regards
dc
|
|
|
|
|
Ah ok. I may be well off the mark here and maybe someone can correct me if so, but you can't call an interface's method directly as it doesn't contain an implementation of that method, only a signature. Therefore, you need to use an object that implements that interface and call the 'Add' method of that object. (A quick Google searched showed that Microsoft.Office.Interop.Outlook.CategoriesClass implements the Categories interface, maybe that is where you should be looking).
Sorry I can't be of more help but I haven't really used the Office Interop assemblies much.
|
|
|
|
|
Ok
and thanks for quick reply
regards
dc
|
|
|
|
|
Hi Liqz
Can any guide me to solve my problem.
i create a setup of outlook VSTO add-in. This setup is not working in Both Winodow XP and Vista.
So my friend suggest me that to write code in Outlook Share Add-In. I again create this share Add-in Setup
and try to run in both machine. But Unfortunately it is not working in XP. And working successful in Vista.
Can any one guide me which file needed to add in XP so my Share Add-in Work on XP also
Regards
DC Confused
|
|
|
|
|
how to convert ascii to hexa using vb?
for example...hexa 13 = ascii 31(1) 33(3)
now i have it in ascii but i need to combine and convert this into 13 instead of 31 33...
i need to create a function to do this in a class library den after dat call it from the app source code
help please!!
thanks alot!!
|
|
|
|
|
so what you need is a function that:
- consumes two characters
- checks they represent one hex digit (30...39,41...46,61...66)
- remember the value, lets call it HI
- consumes two characters
- checks they represent one hex digit (30...39,41...46,61...66)
- remember the value, lets call it LO
- return 16*HI + LO
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Not really sure exactly what you have and what you need, so here's a couple options:
If you have an byte/integer variable and you what the hex string, you need x.ToString("X2")
If you have the two characters '1' and '3' in a string, you need Integer.Parse('13', Globalization.NumberStyles.AllowHexSpecifier)
|
|
|
|
|
I’ve converted code for text justification from C# to VB Express 2005
C# version:
using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;
public class AdvRichTextBox : RichTextBox
{ public new TextAlign SelectionAlignment
{
get
{
PARAFORMAT fmt = new PARAFORMAT();
fmt.cbSize = Marshal.SizeOf( fmt );
SendMessage( new HandleRef( this, Handle ),
EM_GETPARAFORMAT,
SCF_SELECTION, ref fmt );
if ( ( fmt.dwMask & PFM_ALIGNMENT ) == 0 )
return TextAlign.Left;
return ( TextAlign )fmt.wAlignment;
}
set
{
PARAFORMAT fmt = new PARAFORMAT();
fmt.cbSize = Marshal.SizeOf( fmt );
fmt.dwMask = PFM_ALIGNMENT;
fmt.wAlignment = ( short )value;
SendMessage( new HandleRef( this, Handle ),
EM_SETPARAFORMAT,
SCF_SELECTION, ref fmt );
}
}
protected override void OnHandleCreated( EventArgs e )
{
base.OnHandleCreated( e );
SendMessage( new HandleRef( this, Handle ),
EM_SETTYPOGRAPHYOPTIONS,
TO_ADVANCEDTYPOGRAPHY,
TO_ADVANCEDTYPOGRAPHY );
}
private int updating = 0;
private int oldEventMask = 0;
private const int EM_SETEVENTMASK = 1073;
private const int EM_GETPARAFORMAT = 1085;
private const int EM_SETPARAFORMAT = 1095;
private const int EM_SETTYPOGRAPHYOPTIONS = 1226;
private const int WM_SETREDRAW = 11;
private const int TO_ADVANCEDTYPOGRAPHY = 1;
private const int PFM_ALIGNMENT = 8;
private const int SCF_SELECTION = 1;
[StructLayout( LayoutKind.Sequential )]
private struct PARAFORMAT
{
public int cbSize;
public uint dwMask;
public short wNumbering;
public short wReserved;
public int dxStartIndent;
public int dxRightIndent;
public int dxOffset;
public short wAlignment;
public short cTabCount;
[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;
public short wShadingWeight;
public short wShadingStyle;
public short wNumberingStart;
public short wNumberingStyle;
public short wNumberingTab;
public short wBorderSpace;
public short wBorderWidth;
public short wBorders;
}
[DllImport( "user32", CharSet = CharSet.Auto )]
private static extern int SendMessage( HandleRef hWnd,
int msg,
int wParam,
int lParam );
[DllImport( "user32", CharSet = CharSet.Auto )]
private static extern int SendMessage( HandleRef hWnd,
int msg,
int wParam,
ref PARAFORMAT lp );
}
public enum TextAlign
{
Left = 1,
Right = 2,
Center = 3,
Justify = 4
}
}
VB Version
Imports System
Imports System.Windows.Forms
Imports System.Runtime.InteropServices
'<Designer("System.Windows.Forms.Design.ParentControlDesigner, SystemDesign", GetType(IDesigner))> _
<Serializable()> _
Public Class RichTextBoxEx
Inherits RichTextBox
Enum TextAlign
Left = 1
Right = 2
Center = 3
Justify = 4
End Enum
<DllImport("user32", CharSet:=CharSet.Auto)> _
Private Shared Function SendMessage(ByVal hWnd As HandleRef, _
ByVal msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
End Function
<DllImport("user32", CharSet:=CharSet.Auto)> _
Private Shared Function SendMessage(ByVal hWnd As HandleRef, _
ByVal msg As Integer, ByVal wParam As Integer, ByVal lp As PARAFORMAT) As Integer
End Function
<StructLayout(LayoutKind.Sequential)> _
Private Structure PARAFORMAT
Public cbSize As Integer
Public dwMask As UInteger
Public wNumbering As Short
Public wReserved As Short
Public dxStartIndent As Integer
Public dxRightIndent As Integer
Public dxOffset As Integer
Public wAlignment As Short
Public cTabCount As Short
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=32)> _
Public rgxTabs() As Integer
' PARAFORMAT2 from here onwards.
Public dySpaceBefore As Int32
Public dySpaceAfter As Int32
Public dyLineSpacing As Int32
Public sStyle As Short
Public bLineSpacingRule As Byte
Public bOutlineLevel As Byte
Public wShadingWeight As Short
Public wShadingStyle As Short
Public wNumberingStart As Short
Public wNumberingStyle As Short
Public wNumberingTab As Short
Public wBorderSpace As Short
Public wBorderWidth As Short
Public wBorders As Short
End Structure
Private updating As Int32 = 0
Private oldEventMask As Int32 = 0
'Constants from the Platform SDK.
Private Const EM_SETEVENTMASK As Integer = 1073
Private Const EM_GETPARAFORMAT As Integer = 1085
Private Const EM_SETPARAFORMAT As Integer = 1095
Private Const EM_SETTYPOGRAPHYOPTIONS As Integer = 1226
Private Const WM_SETREDRAW As Integer = 11
Private Const TO_ADVANCEDTYPOGRAPHY As Integer = 1
Private Const PFM_ALIGNMENT As Integer = 8
Private Const SCF_SELECTION As Integer = 1
Protected Overrides Sub OnHandleCreated(ByVal e As EventArgs)
MyBase.OnHandleCreated(e)
'Enable support for justification.
SendMessage(New HandleRef(Me, Handle), _
EM_SETTYPOGRAPHYOPTIONS, _
TO_ADVANCEDTYPOGRAPHY, _
TO_ADVANCEDTYPOGRAPHY)
End Sub
Public Overloads Property SelectionAlignment() As TextAlign
Get
Dim fmt As PARAFORMAT = New PARAFORMAT()
fmt.cbSize = Marshal.SizeOf(fmt)
' Get the alignment.
SendMessage(New HandleRef(Me, Handle), _
EM_GETPARAFORMAT, _
SCF_SELECTION, fmt)
' Default to Left align.
If ((fmt.dwMask & PFM_ALIGNMENT) = 0) Then
Return TextAlign.Left
End If
If fmt.wAlignment = 1 Then
Return TextAlign.Left
ElseIf fmt.wAlignment = 2 Then
Return TextAlign.Right
ElseIf fmt.wAlignment = 3 Then
Return TextAlign.Center
ElseIf fmt.wAlignment Then
Return TextAlign.Justify
End If
End Get
Set(ByVal value As TextAlign)
Dim fmt As PARAFORMAT = New PARAFORMAT()
fmt.cbSize = Marshal.SizeOf(fmt)
fmt.dwMask = PFM_ALIGNMENT
fmt.wAlignment = CShort(value)
' Set the alignment.
SendMessage(New HandleRef(Me, Handle), _
EM_SETPARAFORMAT, _
SCF_SELECTION, fmt)
End Set
End Property
End Class
It was working in C# but in vb it gives error that “AccessViolationException was unhandled” at the following line
SendMessage(New HandleRef(Me, Handle), _
EM_SETPARAFORMAT, _
SCF_SELECTION, fmt)
Plz can anyone tell me what's the problem
|
|
|
|
|
In your C# code you pass fmt by reference. This allows the OS to alter it. In VB.Net, you pass it by value; this doesn't. The OS will probably try to alter it, then when it finds it can't, will throw an AccessViolationException. To fix it, pass the fmt variable by reference, using ByRef
Between the idea
And the reality
Between the motion
And the act
Falls the Shadow
|
|
|
|
|
Computafreak wrote: The OS will probably try to alter it, then when it finds it can't, will throw an AccessViolationException.
More importantly, the size will be all wrong because the structure is much larger than a reference.
|
|
|
|
|
I tried using "ByRef fmt" but it gives error saying "Expression required". Am i missing smthg?
P.S: Sorry i hav never b4 worked with "SendMessages"
|
|
|
|
|
I hav done it. thnx to u all.
|
|
|
|
|