|
...In fact, a carriage return line feed is never expected to be found in an RTF file...
Just found that in RTF Specification for Word2007.
I just replace the "\r" "\n" with "\line" in RTF and it worked for now..
CMIIW
Mail me at erwin@holyknight.us
|
|
|
|
|
5 voted for finding the solution yourself, and then remembering to post it for others to see.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi all,
What can I use within C# to replace the function:
LRESULT SendMessage(
HWND hWnd,
UINT Msg,
WPARAM wParam,
LPARAM lParam
);
Many Thanks in advance
Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
OK, so I'm using PInvoke - doing the following:
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]
static extern IntPtr SendMessage(HandleRef hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
But I'm receiving the following error:
Error 2 The modifier 'extern' is not valid for this item
Error 3 Expected class, delegate, enum, interface, or struct
Why ???
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
where did you find "HandleRef"? that's why the compiler expected class, delegate, enum, interface, etc I think..
try the code below.. I have no idea how to use it because it only return the message ID which I don't know how to process..
<br />
[DllImport("user32.dll", CharSet = CharSet.Auto)]<br />
private static extern IntPtr SendMessage(IntPtr hWnd, int wMsg, IntPtr wParam, IntPtr lParam);<br />
CMIIW
Mail me at erwin@holyknight.us
|
|
|
|
|
Where do I place it. At the moment I placed it here (is this correct?
...
using System.IO;
[DllImport("user32.dll", CharSet = CharSet.Auto)]
private static extern IntPtr SendMessage(IntPtr hWnd, int wMsg, IntPtr wParam, IntPtr lParam);
namespace WindowsService
{
...
Many thanks for the reply
Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
Hi,
Programm3r wrote: [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)]static extern IntPtr SendMessage(HandleRef hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
you have to put these lines inside a class, any class would do (I use LP_user32 for all
user32.dll functions).
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Yep,
put it inside a class..
search in microsoft documentation for more info about windows messaging, the message type, and other info..
CMIIW
Mail me at erwin@holyknight.us
|
|
|
|
|
Ok, I'm trying this ....
class WindowsService : ServiceBase
{
[DllImport("user32.dll", CharSet = CharSet.Auto)]
private static extern IntPtr SendMessage(IntPtr hWnd, int wMsg, IntPtr wParam, IntPtr lParam);
But I receive this:
Error 1 The type or namespace name 'DllImport' could not be found (are you missing a using directive or an assembly reference?)
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
using System.Runtime.InteropServices;
All the best,
Martin
|
|
|
|
|
|
Visual Studio is kind enough to include the probable fix in the error message.
MSDN will tell you which namespace DllImport belongs to.
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Add this line to your using directives list:
using System.Runtime.InteropServices;
|
|
|
|
|
|
Is it possible to show a MessageBox from a Service developed in C# ?
Many Thanks
Regards,
The only programmers that are better that C programmers are those who code in 1's and 0's
Programm3r
My Blog: ^_^
|
|
|
|
|
When you say "Service" do you mean that your C# program is running as a Windows Service? That's my assumption here, and yes it's possible. Whether or not it's advisable is another matter.
Now when I say "possible" I mean that the code will compile and build, and the .exe can be installed as a Windows Service and run. Often times one of the main reasons to develop a solution to run as a Windows Service is so that it can run even when no user is logged in to the computer. Now if that's the case, and the code finds it way down the path to where the MessageBox is .Show()'n, I don't know what will happen. Maybe nothing. Maybe it's displayed and causes the Service to stop executing until the nonexistent user clicks the unseen "OK" button.
Of course you could try it and see what happens. If you do, post your results here so everyone can know, too. Then try to find out if a tree falls in the forest....
BDF
|
|
|
|
|
If you need more information on the code...
//Method for converting a structure or object into a byte[]
public static byte[] RawSerialize(object anything)
{
int rawsize = Marshal.SizeOf(anything);
IntPtr buffer = Marshal.AllocHGlobal(rawsize);
Marshal.StructureToPtr(anything, buffer, false);
byte[] rawdatas = new byte[rawsize];
Marshal.Copy(buffer, rawdatas, 0, rawsize);
Marshal.FreeHGlobal(buffer);
return rawdatas;
}
//Method for converting a raw byte[] from a binaryReader stream to the original structure
public static object RawDeserialize(byte[] rawdatas, Type anytype)
{
int rawsize = Marshal.SizeOf(anytype);
if (rawsize > rawdatas.Length)
return null;
IntPtr buffer = Marshal.AllocHGlobal(rawsize);
Marshal.Copy(rawdatas, 0, buffer, rawsize);
object retobj = (Word)Marshal.PtrToStructure(buffer, anytype);
Marshal.FreeHGlobal(buffer);
return retobj;
}
These are the methods I use to convert to byte[] and back to my struct.
|
|
|
|
|
The structure contains a Hashtable. So it wont be possible to get the size of the structure by Marshal.SizeOf(anything) . Hence you wont be able to convert it to byte array using the above method.
jblouir wrote: public Hashtable htWord;
I am not sure whether it is recommended to use Hashtables/Collection classes in a struct.
*jaans
|
|
|
|
|
Ok,
So if I can figure how to store the same data in say...
a string[]
then ill be fine.
This makes things a bit tricky, I guess ill have to use the hashtable storage outside of the struct, then convert it to a string[] and an int[] and I can pull the values out based on index since I will know that string[1]'s value is int[1].
|
|
|
|
|
This didnt work, I change the hashtable to an int[] and it it threw another error.
TypeLoadException was unhandled
'System.Int32[110]' from assembly 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' has too many dimensions.
|
|
|
|
|
SafeArrayTypeMismatchException was unhandled
'System.Int32[110]' from assembly 'mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' has too many dimensions.
This occurs when I change the int[500] to int[50] since the last error sounding like there was too much data
|
|
|
|
|
I managed to get it to work finally, I changed the int[] to just a single int and I was able to load the data after I closed the program. This leaves me with a serious problem though, how am I going to load billions of entries without using some sort of organised format.
sigh..
|
|
|
|
|
In RowDataBound event of GridView the DataControlRowState.Edit
will trigger only alternatively.
If we are binding the column with a RadioButtonList,only alternate columns will only get binded.Is there any solution for this.
Regards
Bino
http://www.technix.co.nr
|
|
|
|
|
private void dgContacts_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
DataGridItem item = e.Item;
if (item.ItemType == ListItemType.AlternatingItem ||
item.ItemType == ListItemType.Item)
{
if ((e.Item.ItemIndex % 2) != 0)
{
LinkButton editButton = item.Cells[0].Controls[0] as LinkButton;
if (editButton != null && editButton.CommandName == "Edit")
{
editButton.Visible = false;
}
}
}
}
Never Think That You Have Failed Instead Always Think That u hav Better Chance Next Time...
|
|
|
|
|
we need to check both conditions (e.Row.Rowstate & DataControlRowSatate)>0
now it will work fine
www.codepal.co.nr
Regards
Bino
http://www.codepal.co.nr
|
|
|
|