|
hi
can you please tell me how can I create a local var that doesn't get destroyed after exiting the method?
thanks
|
|
|
|
|
I'm a bit confused by your question, as objects become eligible for garbage collection when no references to them remain in the code.
Could you provide specifics on what exactly you're trying to do? What kind of variable is this, and what do you plan on doing with it when the method returns?
|
|
|
|
|
I am wondering if it's possible to create a variable in a method as follow:
string tttt = "Gggg";
and then after exiting the method i can still access that var
|
|
|
|
|
No, I think!
But, somebody correct me please.
-- modified at 3:38 Friday 21st July, 2006
|
|
|
|
|
Hello,
If I understand you right???
You have to declare your variable inside your Class and not in the Method.
Or you have to store the Value external (Database or XML).
Hope I helped you.
All the best,
Martin
|
|
|
|
|
Hello
One of the main ideas of C# -if not the main- is being managed by the garbage collector. That's why they call it a managed code -while there is an unmanaged code-. This task is quite advanced and is concerned with memory locations. Even then you'd have to store the memory location -otherwise known as pointer- somewhere to access the value.
You still can do something similar to that in C# with reference type only using WeakReference class. Revise it in your MSDN
Yet again what's exactly your point? Sometimes something that's possible is not always the best solution for a matter!! I'm sure there is a better approach to solve your problem -if it's not a mere programming challenge of some sort-
Regards
|
|
|
|
|
Hi friends,
Please tell me while converting C# gridview to excel how to autofit the columns in excel. Please Help Me.
Thanks & Regards
Prya
|
|
|
|
|
As far as I know, you can select all cells in the gridview and Ctrl+C, Ctrl+V them to Excel.
So nothing special there
WM.
What about weapons of mass-construction?
|
|
|
|
|
Hello
aaraaayen wrote: how to autofit the columns in excel
Do you want to do this in the code -ie programmatically- or just like WilliamM told you??
Besides, what does "autofitting" have to do with C# forum?!!
Regards
|
|
|
|
|
i need to do by programmatically.
Prya
|
|
|
|
|
Hello
What do you mean by "autofit columns"? Do you mean resizing the width of the column to fit the content? You want to write an application to do this inside Excel??!! It's quite strange!!!
Also another point. There are many ways to convert the data in a GridView to Exce format. What's your way in doing it? -If you think it's relevant to the issue at hand-
I think I need more details on exactly what you are planning to do. Maybe I could assist you more.
Regards
|
|
|
|
|
Usually I'm using StreamWriter to write the data in CSV file and import it using Excel.
I always use semicolon as delimiter.
|
|
|
|
|
i have a .h file like below.
how can i use it in C#?
//---------------------------------------------------------------
// AVEControl.h: interface for the AVEControl class.
//
//////////////////////////////////////////////////////////////////////
#if !defined(AFX_AVECONTROL_H__4E171B4B_A11B_49F1_B41C_5F4A31B5CF08__INCLUDED_)
#define AFX_AVECONTROL_H__4E171B4B_A11B_49F1_B41C_5F4A31B5CF08__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
#ifdef DEVICECONTROL_EXPORTS
#define DEVICECONTROL_API __declspec(dllexport)
#else
#define DEVICECONTROL_API __declspec(dllimport)
#endif
typedef HRESULT (*AVECALLBACK) (PBYTE pbData, LONG lDataLength);
#define E_DEVICE_NOT_READY 0xB0004001L
class DEVICECONTROL_API AVEControl
{
public:
HRESULT StartRecordWithoutPreview(HWND hWndCap, CString FileName, __int64 pFileLength, UINT pFileMessage, BOOL pShowSetting = TRUE);
HRESULT StartRecordWithPreview(HWND hWndCap, RECT rc, CString FileName, __int64 pFileLength, UINT pFileMessage, BOOL pShowSetting = TRUE);
HRESULT StartPreview(HWND hWndCap, RECT rc);
HRESULT SetVideoClippingWindow(HWND hwnd);
HRESULT SetCallback(AVECALLBACK Callback);
HRESULT GetVideoStatus(PUCHAR pSta);
HRESULT SetVideoPosition(LPRECT lpSRCRect, LPRECT lpDSTRect);
void GetCurrentImage(CString BmpFileFullName);
BOOL IsGraphRunning(void);
HRESULT StopGraph(void);
HRESULT ApplySettings(CString IniFileFullName);
HRESULT SetVideoProcAmp(long Property, long Value);
HRESULT GetVideoProcAmp(long Property, long* Value);
HRESULT GetEvent(long* EventCode, LONG_PTR* Param1, LONG_PTR* Param2, long msTimeout);
HRESULT SetNotifyWindow(OAHWND hwnd, long lMsg, LONG_PTR lInstanceData);
HRESULT InitDeviceControl(void);
AVEControl();
virtual ~AVEControl();
};
#endif // !defined(AFX_AVECONTROL_H__4E171B4B_A11B_49F1_B41C_5F4A31B5CF08__INCLUDED_)
|
|
|
|
|
you can try to create a DLL using the C++ class. After creating the DLL it's easier to use in c# with [DllImport] command. In c# char* becomes string byte* becomes byte[] and if you pass a value using reference like in your class "long* Value", use "ref log Value".
Hope it helps
Do your best to be the best
|
|
|
|
|
the Question is not the data type.
We can noticed that a class have been defined as below:
{
class DEVICECONTROL_API AVEControl
}
in the head file,
all the functions is defined in the class.
so if i use [DllImport] to define the function in C#,
when run it, an exception is found ,which message as "EntryPoint can not be found in DLL",
So I think the reason is that we cann't use the class from the unmanaged Dll
directly in C#,we have to build a wrapper use C++.net .
but How?
|
|
|
|
|
i created a c++ dll in .net using a code like this:
extern "C"
{
__declspec(dllexport) <method definition="">
{
//method body
}
__declspec(dllexport) <method definition="">
{
//method body
}
}
try it. maybe it will work for you too!
Do your best to be the best
|
|
|
|
|
thank you for your answer.
but I cann't do it.
because the DLL is already exist.
it was from a video capturer SDK.
the head file is defined as in the article.
and all functions have been defined in a class.
if i use [DlImport],compile is right, but when i run, an exception shown with"can not found the entrypoint from .dll".
i think the trouble is the class defination.
so i want to know how to use the class from the dll.
|
|
|
|
|
When a user right-clicks to open a context menu, most native Win32 apps allow the user to then also right-click on a context menu item to choose it.
I am writing a desktop app using WinForms on .NET 1.1. Unfortunately, System.Windows.Forms.MenuItem's Click event only get raised when the user left-clicks a context menu item. This makes my WinForms app feel clunky compared to native Win32 apps.
Is there a workaround to allow WinForms context menu items to be selected with a right-click?
thanks!
chris
-- modified at 21:07 Thursday 20th July, 2006
|
|
|
|
|
|
Hello
Well this right click issue is not a major draw back in WinForms -I think-. Yet you can still do it in C#.
Handle the Click event in your menu, and call a method to do the job from there. Then handle the MouseUp event in your MenuItem, check if(e.Button == MouseButtons.Right), and call the same method.
Regards
|
|
|
|
|
I finished a web site using Visual Studio 2005 ( ASP.NET ) and C# language.
In the Visual Studio internal server, it works perfectly, however after transferring the “SI” folder ( that contains the web site pages ) inside the “C:\inetpub\wwwroot”, and I typed its URL address in the browser, http://pegasus/SI/default.aspx, I get this error message:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Server Error in '/SI' Application.
--------------------------------------------------------------------------------
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: An error occurred loading a configuration file: Failed to start monitoring changes to 'c:\inetpub\wwwroot\web.config' because access is denied.
Source Error:
[No relevant source lines]
Source File: c:\inetpub\wwwroot\web.config Line: 0
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The strange thing is that there is no "web.config" file inside "wwwroot" folder.
How can I fix this problem and make the web site run inside IIS ?
( My OS is Windows XP )
|
|
|
|
|
Hy,
Try creating a virtual folder in IIS and then copy the site in that folder.The folder is located in wwwroot
Do your best to be the best
|
|
|
|
|
Hi
I already have done it but I continue receiving the same error message.
|
|
|
|
|
Hi guys,
I have a picture box with a picture on an mdi form but the problem I am facing is to always having the picture box centered on the mdi form. If the mdi form is maximized than it automatically centers the picturebox and if the mdi form size is reduced than it automatically centers in reference to the mdi form.
Please help!!
sasa
|
|
|
|
|
If you want the picturebox always centred then (if you're only displaying a picture) then you can set the PictureDisplay (or some property along the same lines) to Centre which means the picture will always be displayed in the centre, then dock the PictureBox to Fill and voila.
Other options include handling / overriding the Resize event and using your own code to reposition the picture box as you want.
The Welsh will always support two teams: The Welsh, and anyone playing England
|
|
|
|