|
Anyone know how to disable scroll bars on an MDI frame winform?
|
|
|
|
|
|
It's not work !
|
|
|
|
|
Hello,
I want to display a self-painted Graphic (on-time painted in the program with brush, etc.) in a PictureBox.
This Graphic should be zoomable, so the PictureBox must be scrollable.
Is there a chance to tell the pB, that it has to be scrollable?
Sorry for my english, I hope you understand, what I mean...
Thanks for helping.
Greetz
Torsch
|
|
|
|
|
|
Thank you,
I guess, that's what I want
I'll try it out and give feadback by failing to do this.
Greetz
Torsch
|
|
|
|
|
|
Is there a way I can check to see if the OS is getting shut down within my application? I have overridden the Closing method to hide my application on the tray; much like what the MSN Messenger does. You hit the X on the system menu and my Closing method sets the e.Cancel to true, sets my WindowState to Minimized and Visibility to false. This all works great; until you attempt a Windows shutdown. My e.Cancel seems to tell the OS that it can't stop. If there is a way for me to determine that the OS is calling my Closing method, then I could leave the e.Cancel alone. Any ideas?
Ron Ward
|
|
|
|
|
YeahIGotDotNet posted the code in the VB.NET forum on GotDotNet:
http://www.gotdotnet.com/Community/MessageBoard/Thread.aspx?id=40651&Page=1[^]
It needs a slight modification, since you're overriding the OnClosing method, rather than attaching to the Closing event, and to include the extra cases further down the same discussion:
using System.Diagnostics;
...
protected override void OnClosing(CancelEventArgs e)
{
base.OnClosing(e);
StackTrace t = new StackTrace(false);
StackFrame f = t.GetFrame(6);
switch (f.GetMethod().Name)
{
case "CallWindowProc":
case "DefMDIChildProc":
case "DefFrameProc":
case "ShowDialog":
case "DispatchMessageW":
case "DispatchMessageA":
case "SendMessage":
default:
break;
}
}
I would assume that system shutdown would be the same as the task manager option, but you may want to log the method name just to make sure.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
|
|
|
|
|
When the user initiates a shutdown, or when the OS is is about to shutdown, Windows sends out the WM_QUERYENDSESSION to all top level applications. Applications should return a non-zero to allow the the shutdown to continue. If any application returns zero, the session is not ended. The system stops sending WM_QUERYENDSESSION messages as soon as one application returns zero.
You could override the WndProc (Window Procedure) for you main form, and watch for the WM_QUERYENDSESSION message.
public enum Msg
{
WM_QUERYENDSESSION = 0x0011,
WM_QUIT = 0x0012,
WM_ENDSESSION = 0x0016,
}
protected override void WndProc(ref Message m)
{
switch(m.Msg)
{
case (int)Msg.WM_QUERYENDSESSION:
// your code to handle the end session or respond to it
break;
default:
base.WndProc(ref m);
break;
}
}
Gaulles
http://www.gaulles.com
|
|
|
|
|
Checking for the WM_QUERYENDSESSION and WM_ENDSESSION worked perfectly! Thanks Gaul.
|
|
|
|
|
Anyone know where I could find a sample app that will run a console app & display its output in a windows form?
|
|
|
|
|
Daniel Bright wrote:
Anyone know where I could find a sample app that will run a console app & display its output in a windows form?
Do you want the same identical output on both the console and the Win Form?
Nick Parker
Not everything that can be counted counts, and not everything that counts can be counted. - Albert Einstein
|
|
|
|
|
I don't want the console to display at all, I just want all output to be directed to a textbox or something.
This [^] article explains exactly how it is done in C++, I was just hoping for a C# version of it that is more simplified.
|
|
|
|
|
Use the System.Diagnotics.ProcessStartInfo class, set the UseShellExecute property to false, and the RedirectStandardInput , RedirectStandardError and RedirectStandardOutput properties to true. You can then use the StandardInput , StandardError and StandardOutput properties of the Process object to send input to the program and read the output.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
|
|
|
|
|
Hi Eveyone.. I have sample code of install shield express serial key validation dll. I want to convert this c++ code to c# but i don't know where should i start. I need your help.. Thanks...
Here is the code:
<br />
#include "stdafx.h"<br />
#include <tchar.h><br />
#include <stdlib.h><br />
#include "ValidateSN.h"<br />
<br />
BOOL APIENTRY DllMain( HANDLE hModule, <br />
DWORD ul_reason_for_call, <br />
LPVOID lpReserved<br />
)<br />
{<br />
return TRUE;<br />
}<br />
<br />
LONG WINAPI ValidateSN(HWND hwnd, LPSTR szSrcDir, LPSTR szSupport, LPSTR szSerialNum, LPSTR szDbase)<br />
{<br />
if (_tcslen( szSerialNum ) != SERIALNUMBER_LENGTH)<br />
{<br />
#ifdef _DEBUG //Display Debug information<br />
MessageBox(GetFocus(), "Serial Key is Invalid!", "Validation Failed", MB_OK); <br />
#endif<br />
return VALIDATION_FAILED;<br />
}<br />
<br />
TCHAR szTemp[255];<br />
_tcscpy(szTemp, szSerialNum);<br />
<br />
<br />
LPSTR szField1 = _tcstok( szTemp, TOKEN_SEPERATOR );<br />
LPSTR szField2 = _tcstok( NULL, TOKEN_SEPERATOR );<br />
LPSTR szField3 = _tcstok( NULL, TOKEN_SEPERATOR );<br />
<br />
#ifdef _DEBUG //Display Debug information<br />
CHAR szTmp[1024];<br />
wsprintf(szTmp, "szSerialNum=%s. \nField #1=%s \nField #2=%s \nField #3=%s", szSerialNum, szField1, szField2, szField3);<br />
#endif<br />
<br />
if (ValidateField1(szField1) != VALIDATION_SUCCESS)<br />
{<br />
#ifdef _DEBUG //Display Debug information<br />
MessageBox(GetFocus(), "Serial Key is Incorrect!", "Validation Failed!", MB_OK); <br />
#endif<br />
<br />
return VALIDATION_FAILED;<br />
}<br />
else if (ValidateField2(szField2) != VALIDATION_SUCCESS)<br />
{<br />
#ifdef _DEBUG //Display Debug information<br />
MessageBox(GetFocus(), "Serial Key is Incorrect!", "Validation Failed!", MB_OK); <br />
#endif<br />
<br />
return VALIDATION_FAILED;<br />
}<br />
else if (ValidateField3(szField3) != VALIDATION_SUCCESS)<br />
{<br />
#ifdef _DEBUG //Display Debug information<br />
MessageBox(GetFocus(), "Serial Key is Incorrect!", "Validation Failed!", MB_OK); <br />
#endif<br />
<br />
return VALIDATION_FAILED;<br />
}<br />
else<br />
return VALIDATION_SUCCESS;<br />
}<br />
<br />
LONG ValidateField1(LPSTR szField1)<br />
{<br />
if (_tcsicmp (szField1, SERIALNUM_FIELD1) == 0)<br />
{<br />
return 1;<br />
}<br />
else<br />
return -1;<br />
}<br />
<br />
LONG ValidateField2(LPSTR szField2)<br />
{<br />
<br />
long lNumToValidate = atoi (szField2);<br />
<br />
if ((lNumToValidate % 3) == 0)<br />
return VALIDATION_SUCCESS;<br />
else <br />
return VALIDATION_FAILED;<br />
}<br />
<br />
LONG ValidateField3(LPSTR szField3)<br />
{<br />
return VALIDATION_SUCCESS;<br />
<br />
}
|
|
|
|
|
learn C#
the string object is your friend and the Convert class is your buddy
LPSTR becomes string
all the _t type functions have equivalent methods for string objects
and the atoi can be handled by a Convert.ToInt32(...)
Technically speaking the dictionary would define Visual Basic users as programmers. But here again, a very generalized, liberal definition is being employed and it's wrong - just plain wrong - Tom Archer 5/12/02
|
|
|
|
|
Thanks. but my problem is entry point of function. install shield does not found my function written in c#. i have to export function for external use like this
extern "C" _declspec (dllexport) <br />
int validatethis(const char * szSerial)<br />
{<br />
.....<br />
...<br />
}<br />
i dont know how it is make in c#..
|
|
|
|
|
ah - I see - I assumed that you were just wanting to use the same code in some C# project.
daft question but why are you writing it in C# if it works fine with installshield in the form that you have it?
Anyway what you have to look into is called 'interop', but I don't think you can as I think MS worked on the principle that C# will want to call API but not the other way - a .NET dll is not the same as a normal dll and has different structure and thus LoadLibrary etc will not cope
I think what you might have to do is wrap the C# object in managed C++ (which I think you can export)
Technically speaking the dictionary would define Visual Basic users as programmers. But here again, a very generalized, liberal definition is being employed and it's wrong - just plain wrong - Tom Archer 5/12/02
|
|
|
|
|
Thank you so much... I think i understand. I want to use c# because i use well c# then c++. I will try to do that.. Thanks again..
|
|
|
|
|
Hi all,
I wanna do something like what is done by WinZip or WinRar programs.
when i rightClick any file i found My Menu item after copy & paste for example.
anyone know how to do such things in C#
thanks
plextoR
|
|
|
|
|
What you are talking about here is a Explorer Context Menu Shell Extension.
There are a series of articles written by Mike on how to do this using VC++. If you would like to do the same in C#, there is lot of work to be done. There is a technology sample that comes along with framework sdk, which would help you go about this thing.
Here are the links that could help
The following is one of the samples, but does not directly what you want, but gives you an understanding of things involved in writing one.
http://www.codeproject.com/csharp/dateparser.asp[^]http://www.codeproject.com/shell/shellextguide1.asp[^]
The sample from framework sdk
\FrameworkSDK\Samples\Technologies\Interop\Applications\ShellCmd
Hope this helps.
Cheers
Kannan
|
|
|
|
|
If you don't need the functionality of a COM shell extension then you could get away with some quick registry additions.
Add
HKEY_CLASSES_ROOT\Folder\shell\&Command To Display\command
and set (Default) to pathtoexe\program.exe
You can play with "'s and the command line arguments passed (%1) if needed.
This will display for any folder that's right-click on. You could instead add it under the HKCR\Directory tree or create your own association. It just looks for the shell & command keys.
|
|
|
|
|
Hi
Is there any way to create a control in C# and use it in non .Net (MFC 6) program?
thanks
|
|
|
|
|
Um... no.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|