|
I prefer a single stage compression technique, which if used correctly is extremely compact and fast to decompress. It consists of finding the random number seed that re-generates the input stream. You then only have to transmit the seed, and you are there.
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
That's all hunky dory for handling a local situation, however there are certain legal restrictions that prevent world-wide use of your seeding scheme; e.g. you can't ship most kinds of seeds into Australia.
|
|
|
|
|
"There is no sadder sight in the world than to see a beautiful theory killed by a brutal fact."
Thomas Huxley
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
I had a housemate in back in college who came up with a similar algorithm. He was insitutionalized shortly afterward. The depressing part was that he was able to return the following semester, graduate, and got a full ride to Yale for grad school.
|
|
|
|
|
I know, prior art sunk my patent application.
|
|
|
|
|
I am not able to do still. if you write method....
-----
string myString = stringToBinary("a"); //return value will be 01100001 ( 8 bit )
string stringToBinary(string str)
{
.....
.....
.....
}
|
|
|
|
|
Something like this:
string alphabet = "abcdefg";
char[] chars = alphabet.ToCharArray();
foreach (char character in chars)
Console.WriteLine(Convert.ToString(character, 2).PadLeft(8, '0'));
DaveIf this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier. (Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
Hi,
I have created toolbar for Excel. To one of the toolbar item i am trying associate the image. But it is failing.
stdole.IPictureDisp p = AxHost.GetIPictureDispFromPicture(image) as stdole.IPictureDisp;
commandBarButton.Picture = p;
When I am trying to assigning to command bar picture it is throwing following error.
Error HRESULT E_FAIL has been returned from a call to a COM component. (source: Office)
Exception info:System.Runtime.InteropServices.COMException (0x80004005): Error HRESULT E_FAIL has been returned from a call to a COM component.
at Microsoft.Office.Core._CommandBarButton.set_Picture(IPictureDisp ppdispPicture)
Based on some events this tool bar image is changing.
I am not sure why it failing.But same thing is working for menu bar item.
Please help.
|
|
|
|
|
Are you sure p is not null ?
/ravi
|
|
|
|
|
|
Hi,
I want to make some app startup from the commandline no matter in which folder I am. So I was thinking of putting my executable in the c:\Windows folder.
now if I start the exe from "C:\program files" I want to know this path instead of the Application.StartupPath (which returns "C:\Windows")
Can anybody tell me how to get this path?
Thanks.
Ted
- Life would be so much easier if I had the source code!
- If C# had true garbage collection, most applications would delete themselves upon execution
|
|
|
|
|
found it, this does the trick:
Directory.GetCurrentDirectory();
- Life would be so much easier if I had the source code!
- If C# had true garbage collection, most applications would delete themselves upon execution
|
|
|
|
|
If I have understood your requirement correctly you could create an environment variable to give you accees to your application form anywhere.
On the Advanced tab of System Properties click on the Environment Variables button. Add the path to your app to the PATH variable and you will be able to start it from anywhere.
me, me, me
"The dinosaurs became extinct because they didn't have a space program. And if we become extinct because we don't have a space program, it'll serve us right!"
Larry Niven
|
|
|
|
|
You can pick up the location of many different "special" folders. This will get you the Program Files folder:
string strProgFilesDir = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles);
If, however, you really meant that you wanted the name of the directory where the assembly was located, then you should use:
using System.IO;
.
.
.
string strMyHomeDir = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location);
As an aside, rather than adding a program to the Windows folder, you should create a folder elsewhere (I have one called Tools) and add that folder to your environment Path. Perhaps it's just me but I don't like cluttering up system file locations.
|
|
|
|
|
I was spend for a long time looking for a decision of a problem, about the TextBox control that is included with Windows CE has a very limited opportunities for events related to mouse. I discovered that the team that developed the platform as it is a Compact Edition some controls are "clipped" from "unnecessary" events and an elaborate on them using unmanaged code by hooks and messages from the shell remitted. After a long search Internet and Googl-ing discovered fragments code and I have them so that they become finished code which help us for future implementations. You are welcome!
using System;
using System.Drawing;
using System.Runtime.InteropServices;
internal sealed class Win32
{
public delegate int WndProc(IntPtr hwnd, uint msg, uint
wParam, int lParam);
[DllImport("coredll.dll")]
public extern static int DefWindowProc(IntPtr hwnd,
uint msg, uint wParam, int lParam);
[DllImport("coredll.dll")]
public extern static IntPtr SetWindowLong(IntPtr hwnd, int nIndex,
IntPtr dwNewLong);
[DllImport("coredll.dll")]
public extern static int CallWindowProc(IntPtr lpPrevWndFunc,
IntPtr hwnd, uint msg, uint wParam, int lParam);
public const int GWL_WNDPROC = -4;
public const uint WM_PAINT = 0x000F;
public const uint WM_ERASEBKGND = 0x0014;
public const uint WM_KEYDOWN = 0x0100;
public const uint WM_KEYUP = 0x0101;
public const uint WM_MOUSEMOVE = 0x0200;
public const uint WM_LBUTTONDOWN = 0x0201;
public const uint WM_LBUTTONUP = 0x0202;
public const uint WM_LBUTTONDBLCLK = 0x0203;
public const uint WM_NOTIFY = 0x4E;
}
using System;
using System.Collections;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;
internal class WndProcHooker
{
public delegate int WndProcCallback(IntPtr hwnd, uint msg,
uint wParam, int lParam, ref bool handled);
private static Dictionary<IntPtr, HookedProcInformation> hwndDict = new Dictionary<IntPtr, HookedProcInformation>();
private static Dictionary<Control, HookedProcInformation> ctlDict = new Dictionary<Control, HookedProcInformation>();
public static void HookWndProc(Control ctl,
WndProcCallback callback, uint msg)
{
HookedProcInformation hpi = null;
if (ctlDict.ContainsKey(ctl))
{
hpi = ctlDict[ctl];
}
else if (hwndDict.ContainsKey(ctl.Handle))
{
hpi = hwndDict[ctl.Handle];
}
if (hpi == null)
{
hpi = new HookedProcInformation(ctl,
new Win32.WndProc(WndProcHooker.WindowProc));
ctl.HandleCreated += new EventHandler(ctl_HandleCreated);
ctl.HandleDestroyed += new EventHandler(ctl_HandleDestroyed);
ctl.Disposed += new EventHandler(ctl_Disposed);
if (ctl.Handle != IntPtr.Zero)
{
hpi.SetHook();
}
}
if (ctl.Handle == IntPtr.Zero)
{
ctlDict[ctl] = hpi;
}
else
{
hwndDict[ctl.Handle] = hpi;
}
hpi.messageMap[msg] = callback;
}
static void ctl_Disposed(object sender, EventArgs e)
{
Control ctl = sender as Control;
if (ctlDict.ContainsKey(ctl))
{
ctlDict.Remove(ctl);
}
else
{
System.Diagnostics.Debug.Assert(false);
}
}
static void ctl_HandleDestroyed(object sender, EventArgs e)
{
Control ctl = sender as Control;
if (hwndDict.ContainsKey(ctl.Handle))
{
HookedProcInformation hpi = hwndDict[ctl.Handle];
UnhookWndProc(ctl, false);
}
else
{
System.Diagnostics.Debug.Assert(false);
}
}
static void ctl_HandleCreated(object sender, EventArgs e)
{
Control ctl = sender as Control;
if (ctlDict.ContainsKey(ctl))
{
HookedProcInformation hpi = ctlDict[ctl];
hwndDict[ctl.Handle] = hpi;
ctlDict.Remove(ctl);
hpi.SetHook();
}
else
{
System.Diagnostics.Debug.Assert(false);
}
}
private static int WindowProc(IntPtr hwnd, uint msg,
uint wParam, int lParam)
{
if (hwndDict.ContainsKey(hwnd))
{
HookedProcInformation hpi = hwndDict[hwnd];
if (hpi.messageMap.ContainsKey(msg))
{
WndProcCallback callback = hpi.messageMap[msg];
bool handled = false;
int retval = callback(hwnd, msg, wParam, lParam, ref handled);
if (handled)
return retval;
}
return hpi.CallOldWindowProc(hwnd, msg, wParam, lParam);
}
System.Diagnostics.Debug.Assert(false,
"WindowProc called for hwnd we don't know about");
return Win32.DefWindowProc(hwnd, msg, wParam, lParam);
}
public static void UnhookWndProc(Control ctl, uint msg)
{
HookedProcInformation hpi = null;
if (ctlDict.ContainsKey(ctl))
{
hpi = ctlDict[ctl];
}
else if (hwndDict.ContainsKey(ctl.Handle))
{
hpi = hwndDict[ctl.Handle];
}
if (hpi == null)
{
throw new ArgumentException("No hook exists for this control");
}
if (hpi.messageMap.ContainsKey(msg))
{
hpi.messageMap.Remove(msg);
}
else
{
throw new ArgumentException(String.Format(
"No hook exists for message ({0}) on this control",
msg));
}
}
public static void UnhookWndProc(Control ctl, bool disposing)
{
HookedProcInformation hpi = null;
if (ctlDict.ContainsKey(ctl))
{
hpi = ctlDict[ctl];
}
else if (hwndDict.ContainsKey(ctl.Handle))
{
hpi = hwndDict[ctl.Handle];
}
if (hpi == null)
{
throw new ArgumentException("No hook exists for this control");
}
if (ctlDict.ContainsKey(ctl) && disposing)
{
ctlDict.Remove(ctl);
}
if (hwndDict.ContainsKey(ctl.Handle))
{
hpi.Unhook();
hwndDict.Remove(ctl.Handle);
if (!disposing)
{
ctlDict[ctl] = hpi;
}
}
}
class HookedProcInformation
{
public Dictionary<uint, WndProcCallback> messageMap;
private IntPtr oldWndProc;
private Win32.WndProc newWndProc;
private Control control;
public HookedProcInformation(Control ctl, Win32.WndProc wndproc)
{
control = ctl;
newWndProc = wndproc;
messageMap = new Dictionary<uint, WndProcCallback>();
}
public void SetHook()
{
IntPtr hwnd = control.Handle;
if (hwnd == IntPtr.Zero)
{
throw new InvalidOperationException(
"Handle for control has not been created");
}
oldWndProc = Win32.SetWindowLong(hwnd, Win32.GWL_WNDPROC,
Marshal.GetFunctionPointerForDelegate(newWndProc));
}
public void Unhook()
{
IntPtr hwnd = control.Handle;
if (hwnd == IntPtr.Zero)
{
throw new InvalidOperationException(
"Handle for control has not been created");
}
Win32.SetWindowLong(hwnd, Win32.GWL_WNDPROC, oldWndProc);
}
public int CallOldWindowProc(IntPtr hwnd,
uint msg, uint wParam, int lParam)
{
return Win32.CallWindowProc(oldWndProc, hwnd, msg,
wParam, lParam);
}
}
}
using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace karlovo
{
public partial class TextBoxCustom : TextBox
{
new public event EventHandler DoubleClick;
public TextBoxCustom()
: base()
{
InitializeComponent();
WndProcHooker.HookWndProc(this, new WndProcHooker.WndProcCallback(WindowMessageHandler), Win32.WM_LBUTTONDBLCLK);
}
private int WindowMessageHandler(IntPtr hwnd, uint msg, uint wParam,int lParam, ref bool handled)
{
OnMouseDoubleClick(EventArgs.Empty);
handled = true;
return 0;
}
protected void OnMouseDoubleClick(EventArgs e)
{
if (DoubleClick != null)
{
DoubleClick(this, e);
}
}
}
}
So,all u need to do is to put this code in your custom control and implements the event. Thanks!!!
|
|
|
|
|
What a Great Help!Thank you very much!
|
|
|
|
|
Hi all,
I have a UserControl that manages a lot of editable information (like text-boxes). Now I need to make a version of this control that has a different layout (from horizontal to vertical). I can expose the control, like this:
public TextBox MyText
{
get { return myText; }
set { myText = value; }
}
i can now manually change the location and size, but this does not give me a visual reposition of them at design time.
Is there a better way of doing this ?
Thanks John
|
|
|
|
|
Hi John
How about a property in the control that changes the layout based on the value i.e. myControl.Orientation = Orientation.Vertical where the Orientation.Vertical is an enum held within the control.
Regards
The FoZ
|
|
|
|
|
In my project , we are used Mysql for database ... our application developed in c# winform application . Now we are creating deployment package using Visual studio 2008 ... user can install all prerequisites in a single click ... so i want add mysql also in a package ... how can do this ... please help me ... give some steps for how can achieve this ....
Thankyou
|
|
|
|
|
If Visual Studio's installer builder allows you to execute commands in the installation, you can let the MySQL installer run in silent mode.
I use Inno Setup for installers, so I'm clueless myself. But it's an idea.
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. - Calvin (from Calvin and Hobbes)(The Indispensable Calvin and Hobbes, p105-3)
|
|
|
|
|
I would like to write a program to be able to move a maximized window over to another monitor.
Some posts specify that you should first un-maximize the window, then move and then re-maximize the window.
I did and it works fine, except... it's not really nice to see.
You actually see the resizing of the window and it's slow too.
Moving a non-maximized window is much faster than moving a maximized one.
Any ideas in how to move the window in a nice fashion?
Thus without visual un-maximizing the window?
Thanks for any idea.
|
|
|
|
|
mvermand wrote: Any ideas in how to move the window in a nice fashion?
Thus without visual un-maximizing the window?
Hide it, restore it to a normal windowstate, move it, maximize it and show it again
I are Troll
|
|
|
|
|
Great Idea, but do you know how to hide a window based on its handle?
|
|
|
|
|
|
Hi
I've created a number of user controls to use on forms. What i need to do now is get a enum of variables from the form onto the user controls.
I am trying to write the code in the user control that just looks for a Enum with a fixed name on the form.
Any ideas? The problem i want to be able to reuse these controls on any form aslong as the Enum is there.
Chris
|
|
|
|
|