|
Hi
If i covert any .Net component as COM component using tlbimp.exe then to use that library do i need .Net framework in the target environment?
|
|
|
|
|
satsumatable wrote: tlbimp.exe
I guess you mean tlbexp.exe.
There are only 10 types of people in this world — those who understand binary, and those who don't. |
modified on Thursday, December 31, 2009 2:01 AM
|
|
|
|
|
You are right .. I'm Sorry for the typo.
|
|
|
|
|
Go though this awesome article. Does not answer your question but is a good read for com interop.
There are only 10 types of people in this world — those who understand binary, and those who don't. |
modified on Thursday, December 31, 2009 3:53 AM
|
|
|
|
|
Hi, when uploading a image to a server, I get error saying directory not found. I am guessing its because its trying to find a path of users computer path in server and failing. in my localhost this works fine. how can i modify below code so that below line
System.Drawing.Image.FromFile(System.IO.Path.GetFullPath(flUpload.PostedFile.FileName))
maps to server. is there anyway i can get it working before actually uploading the original image to the server? thank you
using (System.Drawing.Image Img = System.Drawing.Image.FromFile(System.IO.Path.GetFullPath(flUpload.PostedFile.FileName)))
{
Size ThumbNailSize = NewImageSize(Img.Height, Img.Width, 100);
Size ImageSize = NewImageSize(Img.Height, Img.Width, 500);
using (System.Drawing.Image ImgThnail = new Bitmap(Img, ThumbNailSize.Width, ThumbNailSize.Height))
{
ImgThnail.Save(ImageThumbPath, Img.RawFormat);
ImgThnail.Dispose();
}
using (System.Drawing.Image Img1 = new Bitmap(Img, ImageSize.Width, ImageSize.Height))
{
Img1.Save(ImagePath, Img.RawFormat);
Img1.Dispose();
}
Img.Dispose();
}
|
|
|
|
|
Check this link : http://forums.asp.net/t/1079883.aspx[^]
Note: Please post the questions related to asp.net in the correct forum.
"Never put off until run time what you can do at compile time."
- David Gries, in "Compiler Construction for Digital Computers", circa 1969.
|
|
|
|
|
Is code specifically for Windows 7 (through the win7 SDK) ignored if executed on a pre-windows 7 OS? or do you have to do OS version checks before calling any of it? or will it just not run at all?
|
|
|
|
|
You don't have to do anything unless you start using functions that are specific to Windows 7. The Windows SDK is cumulative, meaning that each revision builds on the last one to add support for features in the new O/S. It does NOT mean that the SDK is specific to that version of Windows.
If you're going to use functions that only work on Windows 7, then you've going to have to include code that checks to see if it is running on Windows 7 before it uses those functions.
|
|
|
|
|
Hi im pretty new to programming so any help would be greatly appreciated.
I am trying to create an application that has the following features:
contains two texboxes labeled Formula Name: and Formula Number:
Contains a spreadsheet with 2 columns
Selections from a List Box
Able to total the quantity of the elements in the formula
Being able to print what is typed into the form Spreadsheet, Formula Name, Formula Number
Create a save feature
create an open feature
create a sort A-Z feature
I know how to put the objects in the form but I need help with coding. Any help would be greatly appreciated.
Sincerely,
Steven
|
|
|
|
|
Take help from a C# book (or do a google search) to start writing some code. When you run into any trouble paste your code here and people may be able to guide you.
There are only 10 types of people in this world — those who understand binary, and those who don't. |
|
|
|
|
|
Sound like Excel. Can you not achieve this with Microsoft Excel and macros or other spreadsheet app.
Please confirm if Excel is available to you. A C# solution to this could use VSTO(Visual Studio Tools for Office) api
|
|
|
|
|
yes i have excel but i'm trying to make a simpler program for my friend that has just the basic things that he needs. When he tries typing formulas on excel he becomes overwhelmed for some reason so i'm just trying to help him out.
|
|
|
|
|
If your looking for somthing that will have "math type" formulas... your probably biting off more then you can chew... Math parsing is ... complicated. I believe you can find a simple example app if you search codeProject.
I'd blame it on the Brain farts.. But lets be honest, it really is more like a Methane factory between my ears some days then it is anything else...
|
|
|
|
|
I want to know how can only run a single instance of my application using C# and Win API and bring the application to front if user tried to run another instance?
|
|
|
|
|
|
There's loads of examples of this around - this is the code I use (WinForms) which is adapted from code I found somewhere (can't remember where to give credit )
using System;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Threading;
using System.Windows.Forms;
namespace YourNamespace
{
internal static class SingleInstance
{
#region Fields
private static Form applicationForm = null;
private static string assemblyGuid = null;
private static int message = 0;
private static Mutex mutex = null;
#endregion
#region Properties
private static string AssemblyGuid
{
get
{
if (assemblyGuid == null)
{
object[] attributes = Assembly.GetEntryAssembly().GetCustomAttributes(typeof(GuidAttribute), false);
if (attributes.Length != 0)
assemblyGuid = ((GuidAttribute)attributes[0]).Value;
else
assemblyGuid = string.Empty;
}
return assemblyGuid;
}
}
public static int Message
{
get
{
if (message == 0)
message = NativeMethods.RegisterWindowMessage(String.Format("WM_SHOWFIRSTINSTANCE|{0}", AssemblyGuid));
return message;
}
}
#endregion
#region Methods
public static void Run(Form mainForm)
{
Run(mainForm, false);
}
public static void Run(Form mainForm, bool globalMutex)
{
if (mainForm != null)
{
if (Start(globalMutex))
{
try
{
applicationForm = mainForm;
Application.Run(applicationForm);
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
Stop();
}
}
}
public static void ShowToFront()
{
if (applicationForm != null)
{
NativeMethods.SetWindowPos(applicationForm.Handle, new IntPtr(-1), 0, 0, 0, 0, NativeMethods.SWP_NOMOVE | NativeMethods.SWP_NOSIZE);
NativeMethods.SetWindowPos(applicationForm.Handle, new IntPtr(-2), 0, 0, 0, 0, NativeMethods.SWP_NOMOVE | NativeMethods.SWP_NOSIZE);
NativeMethods.ShowWindow(applicationForm.Handle, NativeMethods.SW_SHOWNORMAL);
NativeMethods.SetForegroundWindow(applicationForm.Handle);
}
}
private static bool Start()
{
return Start(false);
}
private static bool Start(bool globalMutex)
{
bool createdNew = false;
string name = null;
if (globalMutex)
name = String.Format("Global\\{0}", AssemblyGuid);
else
name = string.Format("Local\\{0}", AssemblyGuid);
Mutex thisMutex = new Mutex(true, name, out createdNew);
if (createdNew)
mutex = thisMutex;
else
NativeMethods.PostMessage(
(IntPtr)NativeMethods.HWND_BROADCAST,
Message,
IntPtr.Zero,
IntPtr.Zero);
return createdNew;
}
private static void Stop()
{
mutex.ReleaseMutex();
}
#endregion
private static class NativeMethods
{
#region Constants
public const int HWND_BROADCAST = 0xffff;
public const int SW_SHOWNORMAL = 1;
public const int SWP_NOSIZE = 0x0001;
public const int SWP_NOMOVE = 0x0002;
#endregion
#region Methods
[DllImport("user32")]
public static extern bool PostMessage(
IntPtr hWnd,
int Msg,
IntPtr wParam,
IntPtr lParam);
[DllImport("user32")]
public static extern int RegisterWindowMessage(
string lpString);
[DllImport("user32.dll")]
public static extern bool SetForegroundWindow(
IntPtr hWnd);
[DllImport("user32.dll")]
public static extern bool SetWindowPos(
IntPtr hWnd,
IntPtr hWndInsertAfter,
int X,
int Y,
int cx,
int cy,
int uFlags);
[DllImport("user32.dll")]
public static extern bool ShowWindow(
IntPtr hWnd,
int nCmdShow);
#endregion
}
}
} A small modification to Program.cs
using System;
using System.Windows.Forms;
namespace YourNamespace
{
internal static class Program
{
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
SingleInstance.Run(new FormMain());
}
}
} Then override WndProc in the main form to receive the message so you can bring it to the front
protected override void WndProc(ref Message message)
{
if (message.Msg == SingleInstance.Message)
SingleInstance.ShowToFront();
base.WndProc(ref message);
}
Dave
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Good afternoon.
I was wondering if there was a better was to check for duplicate numbers in an array and if it is not in the array, put it in.
This is what I have so far:
int[] numbers = new int[1000];
private bool RndDuplicate(int intRnd)
{
int index = Array.BinarySearch(numbers, 0, numbers.Length, intRnd);
if (index > 0)
{
return true;
}
else
{
for (int i = 0; i < numbers.Length; i++)
{
if (numbers[i].ToString() == "")
{
numbers[i] = intRnd;
break;
}
}
return false;
}
}
Thank you, WHEELS
|
|
|
|
|
Wheels012 wrote: numbers[i].ToString() == ""
This will always be false.
|
|
|
|
|
How do you check for empty spots (elements?) in a one dimensioal array?
WHEELS
|
|
|
|
|
You can't, an array never has empty spots, it just has entries with the default value, which is 0 (zero) for int. But you can't see the difference between a zero that is there because you never put anything in that place and a zero that you put there.
|
|
|
|
|
Go ahead and univote it. That won't change the truth.
|
|
|
|
|
Some people lack the wisdom to recognize the help they are getting...
|
|
|
|
|
Wheels012 wrote: int[] numbers = new int[1000];
where is this magic 1000 coming from? that is bad code.
Wheels012 wrote: numbers[i].ToString() == ""
and which number will ever have a ToString() result of ""?
the normal approach would be based on a HashSet, not an array.
|
|
|
|
|
I am pretty new to C# and don't know what a HashSet is, but I will look it up. Originally I had the array declaration in the method and set as the numbe rof items on a list, but I thought that would clear the array everytime the method was called.
I believe the find is working well, but I need to load the array with a number (index of list) if it is not currently in there.
WHEELS
|
|
|
|
|
the problem with arrays of integers is, you don't have any "empty" positions, the array initially is filled with zeroes, which could also be valid inputs. the solution is to use some "elastic" collection, that grows when things get added (and even shrinks when things get removed again).
Wheels012 wrote: Originally I had the array declaration in the method ... that would clear the array everytime
correct, whatever you use it should be initialized only once.
Wheels012 wrote: I will look it up
good.
you may learn your code could shrink dramatically...
|
|
|
|