|
If you don't care about the return value, you can just shell to
c:\winnt\system32\timedate.cpl
to pop up the date/time control panel applet.
Sean
|
|
|
|
|
Thank you, Sean. That is very helpful, I'll investigate timedate.cpl. I do need to get the timezone the user selects, without actually changing the PC's settings. This is so a new timezone can be selected for a "World Clock" application.
Thanks again for your help.
John
|
|
|
|
|
Ahhh, sorry, I don't think this will do what you want then. There are no command line parameters passable to the control panel applet (that I can find), and no way to retrieve the value once the user has set it by just shelling to the applet.
I don't think the map selection functionality is exposed as an ActiveX control either.
Sorry 'bout that.
Sean
|
|
|
|
|
I want to dynamically load DLLs (created from VB) and instantiate a class with a particular name, like "ProcessClass".
I am able to load the DLL and confirm there is a class by that name BUT I can't seem to create it or call methods to this newly created instance. I have the following code:
public class Script
{
[DllImport("oleaut32", CharSet=CharSet.Unicode)]
private extern static void LoadTypeLib(string dllFilePath, out UCOMITypeLib typeLibrary);
UCOMITypeLib typeLibrary;
LoadTypeLib(dllName, out typeLibrary);
for (int i = 0; i < typeLibrary.GetTypeInfoCount(); i++)
{
typeLibrary.GetDocumentation(i, out typeName, out typeDocumentation, out typeHelpContext, out typeHelpFile);
if (typeName == "ProcessClass")
{
UCOMITypeInfo typeInformation;
object classInstance;
typeLibrary.GetTypeInfo(i, out typeInformation);
typeInformation.CreateInstance(null, ref guidIUnknown, out classInstance);
MethodInfo method = classType.GetMethod("DoSomething", BindingFlags.InvokeMethod | BindingFlags.Instance | BindingFlags.Public );
method.Invoke(classInstance, new object[0]);
}
}
}
Am I going down the wrong road? The class seems to be created without exception, but the created instance doesn't seem to be bound properly as I don't see any of the methods I'm looking for when I loop through!!
-Ray
|
|
|
|
|
I'm trying to inherit a form an initially am able to do so, however when I build the project I loose the design view for the new inherited form. In the design view tab it says there was an exception 'Request for the permission of type System.Security.Permissions.SecurityPermission failed'
The project still builds and no error is thrown when the form is instantiated at run time. Any ideas where I might be going wrong?
|
|
|
|
|
A lot of my controls don't show nicely in the design view, and I had one that broke the build, although the code would have been fine if it built and ran. I don't bother to fix them, I'd rather have the code look the way I want, than hack for the sake of a view I almost never use.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Is there an artical anywhere describing how to hack around such problems though? I've got a project with a control that generates a null reference exception in the designer with any form that uses it. At long as it's not exceptionally bad how the code looks isn't a major concern since the control's just slurped out of the dll, while the forms involved are being actively modified.
|
|
|
|
|
I found that the problem is that the visual designer tries to render the form, so look through your constructor and any events such as OnPaint, and imagine they are being called without any properties being set. I fixed the one that broke the build by moving code from the init event to another method, and wrapping it in code that guarded against it being called by checking first that everything was in the correct state for it to occur.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi,
I was wondering if any one had some ideas or good places to look for help on a alphnumeric counter.
The count I want to put into place is one that starts at 'AAA000' and continues with 'AAA001' and so on. So when the number hits 999, the next record will have a id of 'AAB000'
Please let me know if you have any ideas or a good site to visit.
Thanks.
|
|
|
|
|
Wow - you asked this in the SQL forum, so I thought you wanted it to be in T-SQL. A counter like this is easy - just define the numeric portion and the letter portion. Then when the numbers hit 1000, roll over and increment a letter.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I'm trying to post a string of xml to another site and I've set up a test script on my own machine to recieve and parse the xml and return a value. When I run that page by itself and feed it some xml, it works fine. But, when I try to call it with the webrequest object, I get an internal server error. Can anyone see what I'm doing wrong here? I've never used this class before so I'm not really sure if I'm doing everything I'm supposed to. Thanks. Oh, and it errors on the line that says WebResponse myWebResponse = myRequest.GetResponse();
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create("http://localhost/test.asp");
myRequest.Method="POST";
myRequest.ContentType = "application/x-www-form-urlencoded";
ASCIIEncoding encoder = new ASCIIEncoding();
// Convert the string into a byte array.
byte[] xmlBytes = encoder.GetBytes("xmlData="+xDoc.InnerXml);
myRequest.ContentLength = xmlBytes.Length;
Stream newStream=myRequest.GetRequestStream();
newStream.Write(xmlBytes,0,xmlBytes.Length);
newStream.Close();
// Return the response.
WebResponse myWebResponse = myRequest.GetResponse();
// Obtain a 'Stream' object associated with the response object.
Stream ReceiveStream = myWebResponse.GetResponseStream();
Encoding encode = System.Text.Encoding.GetEncoding("utf-8");
// Pipe the stream to a higher level stream reader with the required encoding format.
StreamReader readStream = new StreamReader( ReceiveStream, encode );
response = readStream.ReadToEnd();
readStream.Close(); readStream = null;
myWebResponse.Close();
|
|
|
|
|
nevermind. after playing with some other debugging code, I found that the problem ended up being in the page that receives the xml and that it's not receiving it correctly.
|
|
|
|
|
hi to all,
how can i send sql server message to my c# application.
exemple :
in a stored procedure i use the RaiseError keyword with a specific number and description.
all i want to do is to get these two informations in my c# application.
does any know how ?
best regards and thanks in advance
fady
|
|
|
|
|
Use a try/catch and handle the SqlException?
|
|
|
|
|
Hello there.
I was wondering if anyone know if there exist a way to iterate through your named ranges? All I seem to find is:
(Excel.Range)App.get_Range("test", Type.Missing);
Where "test" would be a named range I've specified before manually. I would love to find some easy method like :foreach(NamedRange in ..) etc. So it iterates through all my previously defined names, for example test, test1, test2 etc.
I'm also having large troubles actually getting the name "test" out of anything. rng.Name only gives the address to the range.
I would like this because I want to iterate through all named ranges, sending the name of the range to a webservice and depending on what I would get back I would set a value. Right now I will need to code every specifik instance of them and that will make it harder to add things.
Thanks Christer.
|
|
|
|
|
I'm going insane trying to fix this exception.
I'm building a Browser Helper Object that makes uses of a library that uses GDK-sharp for image handling. GDK-sharp then uses glib-sharp, which then loads libglib-2.0-0.dll so that it can use some of its marshalling code as an extern.
At runtime I get a DllNotFoundException at the point where the DLL is imported into glib-sharp. It claims it can't find libglib-2.0-0.dll. But that DLL is in fact in my path. If I run Filemon it shows the iexplore.exe process successfully loading libglib-2.0-0.dll and its dependencies. Dependency Walker claims I have no missing dependent DLLs. I can't see what could be going wrong here.
One thing might be a lead. When I run it connected to the debugger I get the following error message:
'iexplore.exe': Loaded 'C:\GTK\2.6\bin\libglib-2.0-0.dll', No symbols loaded.
'iexplore.exe': Loaded 'C:\WINDOWS\system32\iconv.dll', No symbols loaded.
First-chance exception at 0x7c964ed1 in iexplore.exe: 0xC0000139: Entry Point Not Found.
I've tried uninstalling and reinstall glib and gtk, but that didn't solve my problem.
Help!
Thanks in advance,
Chris Metcalf
|
|
|
|
|
Hello,
i have a problem with Events ....
i have to use C# and send events to a COM interface
i would like to activate this events by this C#.dll or also through the same COM interface
the COM comunications works but it dosn't fire an event ...
for the test i use a client written in VB6
i would be nice when you can me give any help
(i working with .NET 2003 / VS6.0 on a XPpro)
i have the feeling that ACCOMEvt(src, DateTime.UtcNow); dosn't work rigth ...
here my Code for the server:
using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace ACEvt
{
public delegate void ACDelegate(string Source, DateTime TimeStamp);
[Guid("AC4C1820-04B6-4988-928F-FD858B95C880")]
public interface ACCOMInterface
{
[DispId(1)]
DateTime getACTimestamp();
[DispId(2)]
void ActivateACCOMEvt(string source);
}
[Guid("ACC976E0-C208-4740-AC42-41212D3C34F0"),
InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface ACCOMEvents
{
void ACCOMEvt(string src, DateTime TimeStamp);
}
[Guid("AC5E5FB2-219D-4ee7-AB27-E4DBED8E123E"),
ClassInterface(ClassInterfaceType.None),
ComSourceInterfaces(typeof(ACCOMEvents))]
public class ACCOM : ACCOMInterface
{
public event ACDelegate ACCOMEvt;
public ACCOM()
{
//must be empty !!!!
}
public DateTime getACTimestamp()
{
MessageBox.Show("getACTimestamp");
return DateTime.UtcNow;
}
public void ActivateACCOMEvt(string src)
{
MessageBox.Show("ActivateACCOMEvt");
ACCOMEvt(src, DateTime.UtcNow);
}
}
}
and the VB6 Client without the form:
Option Explicit
Dim WithEvents bmw As AC_Evt.ACCOM
Private Sub Form_Load()
Set bmw = New AC_Evt.ACCOM
End Sub
Private Sub TimeStampBtn_Click()
EvtLst.AddItem bmw.getACTimestamp(), 0
End Sub
Private Sub ActEvtBtn_Click()
bmw.ActivateACCOMEvt ("ActEvtBtn")
End Sub
Private Sub bmw_ACCOM_Evt(ByVal src As String, ByVal Timestamp As Date)
EvtLst.AddItem ">" & src & " " & Timestamp, 0
End Sub
skai007
|
|
|
|
|
Hi,
While reading through many informative articles regarding controls, transparency and alike on C#.
One question remained un-answered every time. How to implement real transparency rather than a fake one.
What is implemented in all the articles is fake, in sense they paint the background of the form, rather than the other controls that are placed underneath the control having transparency.
I myself is quite locked into same situation, and still haven't found no solution.
Compositing mode also didn't help.
Any ideas how to procede and have real transparency enabled.
Thanks.
Jaswinder Singh Kohli
|
|
|
|
|
true transparency is only supported by top level windows (forms)
using "LayeredWindows" api
//Roger
|
|
|
|
|
Hello,
After I retreive the row from the dataset using the select statement:
DataRow[] rowval = dataset.Tables["Versions"].Select("ProjectID = 6 and VersionNumber = 2");
I update some of the values in this row:
rowval[0]["ProjectName"] = "Hello";
rowval[0]["EmployeeID"] = 23;
.
.
.
etc...
How can I insert it back into a dataset, so I can use the update statement
to save the changes into database:
adapterVersions.Update (dataset, "Versions");
Thank you very much
|
|
|
|
|
zaboboa wrote:
How can I insert it back into a dataset,
You don't.
What you get is a reference to a DataRow object. This same reference is contained in the Rows collection of the DataTable in the DataSet .
So, effectively, there's only one row object, and if you modify it somewhere, everybody who has a reference to that particular object will see the changes. In this case, since the DataTable (DataSets don't contain rows) has a reference to the same row you have, it will see the changes. You get the actual row, not a copy of it.
I hope this helps.
-- LuisR
Luis Alonso Ramos
Intelectix - Chihuahua, Mexico
Not much here: My CP Blog!
|
|
|
|
|
Hello guys,
I am trying to create a transparent form using CreateWindowEx() by calling
the unmanaged code. But everytime after the call the returned handle is zero.
i could not figure what is the problem in that...
Here is the code
--------------
[DllImport("User32", SetLastError=true)]
internal static extern int CreateWindowEx ( int dwExStyle, string
lpClassName,
string lpWindowName, int dwStyle, int X, int Y, int nWidth, int nHeight,
int hWndParent, int hMenu, int hInstance, IntPtr lpParam);
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
public struct WNDCLASSEX
{
public uint cbSize;
public uint style;
public long lpfnWndProc;
public int cbClsExtra;
public int cbWndExtra;
public long hInstance;
public long hIcon;
public long hCursor;
public long hbrBackGround;
public string lpszMenuName;
public string lpszClassName;
public long hIconSm;
}
[DllImport("User32.Dll")]
public static extern int RegisterClassEx(ref WNDCLASSEX wndcls);
[DllImport("user32.dll")]
public static extern int ShowWindow(long hwnd, int nCmdShow);
private string classname = "TestYetTransparency";
private void init()
{
// Let's create a window
IntPtr
hInst=Marshal.GetHINSTANCE(System.Reflection.Assembly.GetExecutingAssembly().GetModule("TestYetTransparency.exe"));
WNDCLASSEX wndclass=new WNDCLASSEX();
wndclass.cbSize = (uint) Marshal.SizeOf(typeof(WNDCLASSEX));
wndclass.style = 11; //CS_HREDRAW+CS_VREDRAW+CS_DBLCLKS;
wndclass.lpfnWndProc = 0;
wndclass.cbClsExtra = 0;
wndclass.cbWndExtra = 0;
wndclass.hInstance = hInst.ToInt32();
wndclass.hIcon = 0;
wndclass.hCursor = 0;
wndclass.hbrBackGround = 0;
wndclass.lpszMenuName = "TestYetTransparency";
wndclass.lpszClassName = classname;
wndclass.hIconSm = 0;
int mm = RegisterClassEx(ref wndclass);
int nativeHandle = CreateWindowEx(WS_EX_TRANSPARENT,classname,"transparent"
,WS_BORDER,0,0,Screen.PrimaryScreen.Bounds.Width,Screen.PrimaryScreen.Bounds.Height
,0,0,hInst.ToInt32(),IntPtr.Zero);
ShowWindow(nativeHandle,5); //SW_SHOW
}
private int WS_EX_TRANSPARENT = 0x00000020;
private int WS_BORDER = 0x800000;
------------------
Anyway help in this regard is highly appreciated.
thanks
|
|
|
|
|
Why don't you just use the Form.Opacity property?
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Actually let me explain the problem in detail. Actually i am developing an ink based application. So i need to develop a transparent form where on which i can write on it. But when i set the opacity even the ink is becoming transparent. So i thought not to use this property.
I read somewhere in other groups that when a form is created it is created normarly with out WS_EX_TRANSPARENCY property set. Even setting the opacity does not set the value. So i thought of creating a form of this type and can write on it.
I hope this explains quite a bit why i am looking forward in this direction.
vinod
|
|
|
|
|
I don't know how to use Threads in C#.
I want to check if a website is loaded or not. If not loaded, wait for 3 secs and check again. If still not loaded do something.
Please help me with some pointers.
Thanks in advance
Vishal...
|
|
|
|
|