|
Guffa wrote: A forum doesn't work that way. You get the response in the forum or not at all.
Besides, CP will notify you by email when someone responds to your post, which is quite handy!
“Time and space can be a bitch.”
–Gushie, Quantum Leap
{o,o}.oO( Looking for a great RSS reader? Try FeedBeast! )
|)””’) Built with home-grown CodeProject components!
-”-”-
|
|
|
|
|
Hi friends
I have a structure shown below. I want to convert below structure into bytes or chars array. I like to sent converted chars or bytes to remote computer using socket communication.
public struct _some_data
{
int no;
char []name = new char[15];
int total;
double percent;
}
thanks in advance
-RisKhan-
|
|
|
|
|
I haven't tried this myself but this[^] may help.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Expect everything to be hard and then enjoy the things that come easy. (code-frog)
|
|
|
|
|
You can serialize it.
[Serializable]
public struct SomeStruct
{
public int no;
public char[] name;
public int total;
public double percent;
public SomeStruct(int no,int total,double percent){
this.no = no;
this.total = total;
this.percent = percent;
name = new char[15];
}
} Use BinaryFormatter to serialize this structure.
SomeStruct structInstance = new SomeStruct(10,10,100);
BinaryFormatter formatter = new BinaryFormatter();
byte[] b;
using(MemoryStream stream = new MemoryStream())
{
formatter.Serialize(stream, structInstance);
b = stream.GetBuffer();
}
|
|
|
|
|
Here is the solution : Fast and Easy :
You have to serialize (binary) your struct in a MemoryStream object. then you get the byte array from your memory stream
public byte [] GetBytes (_some_data d)
{
BinaryFormatter bf = new BinaryFormatter();
MemoryStream ms = new MemoryStream();
bf.Serialize(ms, s);
byte [] b = ms.ToArray();
return b;
}
you have to mark you struct as serializable add [Serializabe]
and to use those namespaces
System.Runtime.Serialization;
System.Runtime.Serialization.Formatters.Binary;
|
|
|
|
|
thanks friends, i can got three solution, it will try all and take the best.
-RisKhan-
|
|
|
|
|
you are welcome
|
|
|
|
|
hi
how to add winform in workflow ??!??
|
|
|
|
|
Please Don't post repeated question with subject
Cheers!!
Brij
|
|
|
|
|
You could have used same post to ask two (one liner) questions.
In a way that would have helped you and the other members.
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
hi
how set ifelse activity in workflow ??!??
|
|
|
|
|
I want to know some of the most advantages and disadvantages of WPF in comparison to the Forms . now i started to develop a audio converter and compresser application ,which application is sutiable for this
thank U
|
|
|
|
|
Hello,
i think that when you are developping your application presentation layer have to be (must be) independent of your buisieness/datamodel/audio converter,compresser core layers...
Then when you have finished to developp your converter/compresser core, then you have to think about presentation/GUI.
Well Well
in WPF you can do some very beautiful things (à la vista gadgets, transparency, shaped forms, easy animations if your are using Expression suite...)
with WinForms you can also skin your application and make the strangest user controls you want.
but still your to keep in mind : Usability !
a beautiful/magic/whaou GUI doesn't mean a usabe GUI
|
|
|
|
|
lisan_al_ghaib wrote: vista gadgets
Actually, Vista Gadgets are not WPF, they're some weird DHTML thing.
However, WPF is very cool, but (imo) very complicated. I am still trying to learn it, but there's a steep learning curve. WinForms was much easier to pick up, even if it is rather limited in comparison.
My answer is if you want it done quickly, use WinForms. If you want this to be a mainstream modern "wow" interface, look into WPF.
“Time and space can be a bitch.”
–Gushie, Quantum Leap
{o,o}.oO( Looking for a great RSS reader? Try FeedBeast! )
|)””’) Built with home-grown CodeProject components!
-”-”-
|
|
|
|
|
Sorry I thought that vista gadgets were made with WPF...but DHTML
ouch ouch ouch
When MS released their .net 3.0 and visual studio 2008 i feel a little bit lost !
So many things ! Sooooo many new things
I agree with you that WPF is a complicated !
|
|
|
|
|
HI ALL ,
I'd a small form program it's showing a error is: The name of the 'form1'does not exist in current content(line:41)
Can u help me.
Advance thanks 'U'
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace painthello
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
Form form1 = new Form();
Form form2 = new Form();
form1.Text = "Paint Event";
form1.BackColor = Color.MidnightBlue;
form1.Paint += new PaintEventHandler(MyPaintHandler);
form2.Text = "Paint Event2";
form2.BackColor = Color.MistyRose;
form2.Paint += new PaintEventHandler(MyPaintHandler);
form1.Show();
form2.Show();
}
static void MyPaintHandler(object objectSender, PaintEventArgs pea)
{
Form form = (Form)objectSender;
Graphics grp = pea.Graphics;
String str;
if (form == form1)/// here the error:The name of the 'form1'does not exist in current content
{
str = "hello from the first paint event";
}
else
str = "hello from the second paint event";
//str = "hello from the" + form.Text;
grp.DrawString("HELLO,WORLD!", form.Font, Brushes.BlanchedAlmond, 3, 8);
}
}
}
madhu
|
|
|
|
|
madhu Rao wrote: I'd a small form program it's showing a error is: The name of the 'form1'does not exist in current content(line:41)
Seems like you had change the form name, but it does not get reflected in code, check the name of form in code.
regards
|
|
|
|
|
Hello,
how can i minimize, maximaze, show, hide or close a Window from a Process?
I know how to list all Processes, or the Processes which have a MainWindow, but how can i access that Window and do something with it?
Thanks
|
|
|
|
|
softwarejaeger wrote: how can i minimize, maximaze, show, hide or close a Window from a Process?
P-Invoke ? If you have the window handle, you can use SetWindowPlacement[^] function to set minimize, maximized or restored states.
|
|
|
|
|
OK, thanks but...
how do i use this in c#? i get everytime a lot of errors
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential)]
struct WINDOWPLACEMENT
{
internal int Length;
internal int flags;
internal int showCmd;
internal System.Drawing.Point ptMinPosition;
internal System.Drawing.Point ptMaxPosition;
internal System.Drawing.Rectangle rcNormalPosition;
}
[DllImport("user32")]
public static extern int SetWindowPlacement(int hwnd, ref WINDOWPLACEMENT lpwndpl);
public class TestClass
{
}
The Debugger told me, that in the line public static extern int a class,delegate or something else is expected, it underlines me the "int"... what to do? And when i delete the int it told me that "extern" isn't valid for this item...
|
|
|
|
|
|
Hi,
Set WindowState property of your form to
FormWindowState.Maximized or
FormWindowState.Minimized for maximizing and minimizing the Form.
Refer to this [^]
To Show/Hide and Close the form, use use Form.Hide/Close/Show.
E.g. to show the current form, use this.Show()
I hope this would be helpful.
John Adams
ComponentOne LLC.
www.componentone.com
|
|
|
|
|
hi
this is about process not about Forms
I see A Code Snippet in vs.net 2008 about this but Not remember that code
tanx
|
|
|
|
|
Importing user32.dll and using ShowWindow function with window handle is another solution:
Here is a piece code u may use:
[System.Runtime.InteropServices.DllImport("User32.dll")]
static extern long ShowWindow(int windowHandle, int nCmdShow);
private const int SM_SHOWMAXIMIZED = 3;
private const int SM_SHOWMINIMIZED = 2;
Always keep the Murphy Rules in mind!
|
|
|
|
|