|
Can't you just set those properties on the form in the designer ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
In Properties set control box to false.
|
|
|
|
|
Hi,
I am transforming an input XML documnet using XSL. I have a follg code to do that. The issue is that in my o/p XML, I have a few empty tag elements - When I test my xsl using XMLSPY, the o/p xml contains empty tag elements with short tags in it, which is desired (i.e. <mytag attrvalue="abc"/> ).
However, XML generated from C# code, has the empty tag elements with expanded end tag (i.e. <mytag attrvalue="abc"> </mytag>). This is not what I want.
Does anyone know how to tell C# code/class to create short end tags (i.e. singleton type). Below is my C# code:
public XmlDocument TransformXml(XmlDocument doc, string xslFile)
{
StringBuilder sb = new StringBuilder();
TextWriter tw = new StringWriter(sb);
XslTransform xsl = new XslTransform();
xsl.Load(xslFile); //load xsl file
xsl.Transform(doc, null, tw, null); //does transformation
XmlDocument ret = new XmlDocument();
ret.LoadXml(sb.ToString());
return ret;
}
Thanks,
Ken
|
|
|
|
|
what are the differences?
|
|
|
|
|
When you compile in debug mode, it creates debug information so that you can use the debugger. Also you get more information in the error messages.
---
b { font-weight: normal; }
|
|
|
|
|
|
Additionally to the debug information no optimizations are done.
Some optimizations would make it hard to debug your code (i.E. inlining, removal of unused variables, loop-unwinding etc.).
In release mode those optimizations make your program run faster (not always notable, depends on your design and what your program does.)
/cadi
24 hours is not enough
|
|
|
|
|
|
Hi,
I wanted from my server computer running XP, log off/lock a client machine found on my home network using C#. Is that possible? Give me some hints..
|
|
|
|
|
Off the top of my head...
You can set up a client/server application on the two machines respectively, and then send a certain message from the client program to the waiting server and depending on the message received have the server execute that particular command, whether it be shut down, log off, lock etc.
On the server to log off, shut down and junk, look into the windows api and pinvoke the needed functions to preform those operations. Off the top of my head to shut down is ExitWindowsEx , just poke around it shouldn't be hard to find.
But, once you log out remotely, you won't be able to log back in remotely. I don't think...
/\ |_ E X E GG
|
|
|
|
|
right thanks.. any one has an actual sample of a code of a form with a lock/unlock button on the client where i can log off or lock the client. Once i know how to do that locally, I should be able to do it remotely. thanks
|
|
|
|
|
Hi,
I have two Forms (A and B). When Form A is active I open Form B. I then want to run some code automatically in Form A when I close Form B. How do I do that?
Thanks,
Carl-Johan Larsson
|
|
|
|
|
I assume FormB is not modal - that is, you show it so that it floats but you can still use FormA ( you call Show instead of ShowDialog ). You need to create a function in FormA that looks like this:
private static void dlg_Closed(object sender, EventArgs e)
{
}
then before you show FormB in FormA, you do this ( assuming dlg is the name of your FormB class instance:
dlg.Closed += new EventHandler(dlg_Closed);
There is also a Closing event, which get's called BEFORE the form closes. Now add your code to the method you added to FormA.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Did the trick, Thanks Carl-Johan Larsson
|
|
|
|
|
|
Awesome! Thanks for the info. Looking forward to the Wintellect PowerThreading library I've heard to be in the works...
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Homosexuality in Christianity
Judah Himango
|
|
|
|
|
I'm writing a small app, and I have to prepare a form which will authenticate users. This is the code I wrote. The problem is I get exception in the marked line : "no value given for for on or more required parameters"
What is wrong with it?
Table name is users.
Column name is UserName
<br />
public void userExists(string username)<br />
{<br />
try<br />
{
string sqlFinduser = "SELECT COUNT(UserName) AS UserNameExists " +<br />
"FROM users " +<br />
"WHERE (UserName=" + username + ")";<br />
<br />
OleDbCommand cmdFindsqlFinduser = new OleDbCommand();<br />
<br />
cmdFindsqlFinduser.Connection = cnSurvey;<br />
cmdFindsqlFinduser.CommandType = CommandType.Text;<br />
cmdFindsqlFinduser.CommandText = sqlFinduser;<br />
<br />
cnSurvey.Open();<br />
<br />
int count = int.Parse(cmdFindsqlFinduser.ExecuteScalar().ToString()); <br />
<br />
bool exists = count != 0 ? true : false;<br />
<br />
cnSurvey.Close();<br />
<br />
}<br />
catch(Exception ex)<br />
{<br />
MessageBox.Show(ex.Message);<br />
}<br />
<br />
}<br />
<br />
TIA,
Ronen
|
|
|
|
|
That means that you have one or more names in your query that the database does not regognise.
You have forgotten the apostrophes around the value for username. The database will try to interpret the username as being an identifier, not a string.
---
b { font-weight: normal; }
|
|
|
|
|
How about changing
(UserName=" + username + ")"
to
(UserName='" + username + "')"
assume: username = "abc"
Current code: (UserName = abc)
Fixed code: (UserName = 'abc')
|
|
|
|
|
|
Hey everyone, a quick thanks for taking a look at this...
Basically, my problem is this... I have a "Core" library which contains a "Manager" component, and I want to use this component in C#. This component is written in C++, and here is the IDL file defining its type library.
<br />
import "unknwn.idl";<br />
<br />
[<br />
object,<br />
uuid(822A2EDE-09F1-45b8-B80E-A32F21415677),<br />
helpstring("Interface used by the Manager")<br />
]<br />
<br />
interface IManager : IUnknown<br />
{<br />
HRESULT GetAppName([out, size_is(, *pcMax)] char **ppAppName,<br />
[out] long *pcMax);<br />
<br />
HRESULT SetStatus([in] long cLength,<br />
[in, size_is(cLength)] char* id,<br />
[in] int s);<br />
};<br />
<br />
[<br />
uuid(AE068C74-0B8B-4041-8CA9-4A590DDDC382),<br />
helpstring("Core Component Library")<br />
]<br />
library Core<br />
{<br />
importlib("stdole32.tlb");<br />
importlib("stdole2.tlb");<br />
<br />
interface IManager;<br />
}<br />
Now, if I write a C++ app to use this component, doing this, it works great...
(Keep in mind, the component is registered in the registry and the DLL creates an instance of the component by using IClassFactory)
<br />
#include "stdafx.h"<br />
#include <objbase.h><br />
#import "Core.tlb"<br />
<br />
int main(int argc, char* argv[])<br />
{<br />
HRESULT hr = NULL;<br />
CLSID clsid;<br />
<br />
::CoInitialize(NULL);<br />
<br />
Core::IManager* pManager;<br />
hr = CLSIDFromProgID(OLESTR("Core.1"), &clsid);<br />
<br />
if(FAILED(hr))<br />
{<br />
cout << "DLL not installed correctly" << endl;<br />
}<br />
<br />
hr = ::CoCreateInstance(clsid, NULL, <br />
CLSCTX_ALL, __uuidof(Core::IManager), (void** )&pManager);<br />
<br />
<br />
if(SUCCEEDED(hr))<br />
{<br />
cout << "Found component!" << endl;<br />
<br />
}<br />
}<br />
No problem, it executes just fine, my C++ app easily uses the component.
Now, I try importing "Core.tlb" into .NET, by using tlbimp.exe, I get a useless managed assembly... After pouring through MSDN article after MSDN article, I've come to the conclusion that its possible to create a COM class wrapper? However, I've had no luck with that as well... This is all I've been able to come up with, but I know it doesn't work...
<br />
namespace Core<br />
{<br />
[Guid("822A2EDE-09F1-45b8-B80E-A32F21415677"),<br />
InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]<br />
interface IManager<br />
{<br />
void GetAppName(<br />
[Out, MarshalAs(UnmanagedType.BStr)] string strAppname,<br />
[Out] int maxSize);<br />
<br />
void SetTestPointStatus(<br />
[In] int MaxLength,<br />
[In, MarshalAs(UnmanagedType.BStr)] string id,<br />
[In] int status);<br />
}<br />
<br />
[ComImport, Guid("AE068C74-0B8B-4041-8CA9-4A590DDDC382")]<br />
class CManager<br />
{<br />
}<br />
}<br />
Anyone have any suggestions? I've come to the conclusion that I really have no idea what I'm doing in C# as far as interop goes, I'm not a bad C# coder, but this just escapes me at the moment...
Anyway, thanks again for reading this
|
|
|
|
|
Hi!
In your C# project, just add a reference to your COM object (in project explorer, select "Add reference..." and find your COM class on the COM tab).
VS.NET will create the interop assembly and you can immediately use your COM class.
Typing "Core." should already give you intellisense for IManager, CManager and so on.
Regards,
mav
|
|
|
|
|
First, thank you very much for your advice...
Hmmm, I've tried that, but like I said, I don't really have that usable of an interop assembly... It only gives me Core::IManager, just the interface... Do I have to implement that interface, or write a wrapper for that? There are no class objects for me to instantiate... Some sites talk about coclasses, but I have none defined in my IDL file, and I'm not really sure what I'm doing as far as that... haha, am I just doing this wrong?
Thanks again
|
|
|
|
|
Ok, now that I've taken a second look at the IDL, there in fact isn't a CoClass defined, so all you'll get will be IManager. This is correct so far.
What puzzles me is that you claim that it does work with C++/CoCreateInstance...
I didn't find any class actually implementing IManager, so which class is created by the class factory?
mav
|
|
|
|
|
I have a program, it's a form, a GUI. I need it to close when I hit the x-button in the corner. It is still running in the processes after I close it. How do I permenantly kill the program?
I tried this:
private void ExitButton_Click(object sender, System.EventArgs e)
{
this.Close();
}
thanks very much!
|
|
|
|
|