|
madhu Rao wrote: I'd a small form program it's showing a error is: The name of the 'form1'does not exist in current content(line:41)
Seems like you had change the form name, but it does not get reflected in code, check the name of form in code.
regards
|
|
|
|
|
Hello,
how can i minimize, maximaze, show, hide or close a Window from a Process?
I know how to list all Processes, or the Processes which have a MainWindow, but how can i access that Window and do something with it?
Thanks
|
|
|
|
|
softwarejaeger wrote: how can i minimize, maximaze, show, hide or close a Window from a Process?
P-Invoke ? If you have the window handle, you can use SetWindowPlacement[^] function to set minimize, maximized or restored states.
|
|
|
|
|
OK, thanks but...
how do i use this in c#? i get everytime a lot of errors
using System.Runtime.InteropServices;
[StructLayout(LayoutKind.Sequential)]
struct WINDOWPLACEMENT
{
internal int Length;
internal int flags;
internal int showCmd;
internal System.Drawing.Point ptMinPosition;
internal System.Drawing.Point ptMaxPosition;
internal System.Drawing.Rectangle rcNormalPosition;
}
[DllImport("user32")]
public static extern int SetWindowPlacement(int hwnd, ref WINDOWPLACEMENT lpwndpl);
public class TestClass
{
}
The Debugger told me, that in the line public static extern int a class,delegate or something else is expected, it underlines me the "int"... what to do? And when i delete the int it told me that "extern" isn't valid for this item...
|
|
|
|
|
|
Hi,
Set WindowState property of your form to
FormWindowState.Maximized or
FormWindowState.Minimized for maximizing and minimizing the Form.
Refer to this [^]
To Show/Hide and Close the form, use use Form.Hide/Close/Show.
E.g. to show the current form, use this.Show()
I hope this would be helpful.
John Adams
ComponentOne LLC.
www.componentone.com
|
|
|
|
|
hi
this is about process not about Forms
I see A Code Snippet in vs.net 2008 about this but Not remember that code
tanx
|
|
|
|
|
Importing user32.dll and using ShowWindow function with window handle is another solution:
Here is a piece code u may use:
[System.Runtime.InteropServices.DllImport("User32.dll")]
static extern long ShowWindow(int windowHandle, int nCmdShow);
private const int SM_SHOWMAXIMIZED = 3;
private const int SM_SHOWMINIMIZED = 2;
Always keep the Murphy Rules in mind!
|
|
|
|
|
|
I have used the caching and logging application block. It worked well.
|
|
|
|
|
Hi all,
I've added multiple tab pages in a form and set some data to each using a list view. Basically I've added data to the list view using a open dialog. Initially I'm added data to the tab page one. If I add another data to the form, if the tab page 0ne contain data, want to added data to the next tab page.
How can I do it.
I appreciate your help all the time...
CodingLover
|
|
|
|
|
I dont think I understand your question.
open dialog and get the data.
after dialog closes create a new tab, add it to the tab collection,
add the controls to the tab and load them with data.
Natza Mitzi
|
|
|
|
|
Ok, I'll explain more. On a button click event I add data to a tabpage as follows.
<br />
private void OpenLocalFile()<br />
{<br />
BackgroundWorker backgroundWorkerOpenFile; <br />
OpenFileDialog fd = new OpenFileDialog();<br />
<br />
fd.Filter = "Word File (*.doc)|*.doc|Text File (*.txt)|*.txt|All supported File|*.doc;*.txt";<br />
fd.FilterIndex = 3;<br />
fd.RestoreDirectory = true;<br />
if (fd.ShowDialog(this) == DialogResult.OK)<br />
{<br />
CloseFile();<br />
backgroundWorkerOpenFile.RunWorkerAsync(fd.FileName);<br />
FileInfo fi = new FileInfo(fd.FileName);<br />
tabPage1.Text = fi.Name;<br />
}<br />
}<br />
On the first button click call this function and added data to the tab page 1. In the next click I want to check on the all tab pages and add data to the first empty content tab page.
Hope it's clear now.
I appreciate your help all the time...
CodingLover
|
|
|
|
|
Hi guys.
I want to put a checkBox in menuStrip.
Do you know how can I do it ?
Thank you
|
|
|
|
|
Mohammad Dayyan wrote: Do you know how can I do it ?
Yes I do. Thanks for asking.
Well you could always set the CheckOnClick property of a menu item to true.
|
|
|
|
|
Oh.I'm sorry for my question.
Pete O'Hanlon wrote: Well you could always set the CheckOnClick property of a menu item to true.
Thank you Pete .
But it doesn't thing that I want.
I want to put CheckBox Control (or Button control) in a menuStrip.
|
|
|
|
|
This class will do what you want - it may need some expanding to expose the checkboxes properties and events you need. You can add more controls to the flowlayoutpanel for a multicontrol control, or change the checkbox for a button or whatever.
using System;
using System.Drawing;
using System.Windows.Forms;
public class CheckBoxToolStripItem : ToolStripControlHost
{
private FlowLayoutPanel controlPanel;
private CheckBox chk = new CheckBox();
public CheckBoxToolStripItem()
: base(new FlowLayoutPanel())
{
controlPanel = (FlowLayoutPanel)base.Control;
controlPanel.BackColor = Color.Transparent;
chk.AutoSize = true;
controlPanel.Controls.Add(chk);
}
public bool Checked
{
get { return chk.Checked; }
set { chk.Checked = value; }
}
public new string Text
{
get { return chk.Text; }
set { chk.Text = value; }
}
protected override void OnSubscribeControlEvents(System.Windows.Forms.Control control)
{
base.OnSubscribeControlEvents(control);
chk.CheckedChanged += new EventHandler(CheckedChanged);
chk.TextChanged += new EventHandler(TextChanged);
}
protected override void OnUnsubscribeControlEvents(System.Windows.Forms.Control control)
{
base.OnUnsubscribeControlEvents(control);
chk.CheckStateChanged -= new EventHandler(CheckedChanged);
chk.TextChanged -= new EventHandler(TextChanged);
}
private void CheckedChanged(object sender, EventArgs e)
{
}
private new void TextChanged(object sender, EventArgs e)
{
}
} You can then create and add your item like this
CheckBoxToolStripItem chk = new CheckBoxToolStripItem();
chk.Text = "ABC";
chk.Checked = true;
menuStrip1.Items.Add(chk);
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Expect everything to be hard and then enjoy the things that come easy. (code-frog)
|
|
|
|
|
Research ToolStripControlHost.
“Time and space can be a bitch.”
–Gushie, Quantum Leap
{o,o}.oO( Looking for a great RSS reader? Try FeedBeast! )
|)””’) Built with home-grown CodeProject components!
-”-”-
|
|
|
|
|
Hi all,
I'm looking for an easy way to send message containing String data from C# application to C++ application, using the SendMessage API call.
Please refer to both sending the message and receiving it (in C++).
Thanks a lot!
Eyal.
|
|
|
|
|
are both applications exe ?
|
|
|
|
|
Yes, both Windows applications. One's GUI is written on .NET 2 C# and the second is C++ application with GUI designed using FLTK.
Thank you.
|
|
|
|
|
On the C# side, something like this maybe:
[DllImport("User32", SetLastError = true)]
public static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
...
string ManagedString = "A string!";
IntPtr PtrToUnmanagedString = Marshal.StringToHGlobalAnsi(ManagedString);
SendMessage(hwnd, WM_SOMEMESSAGE, IntPtr.Zero, PtrToUnmanagedString);
Marshal.FreeHGlobal(PtrToUnmanagedString);
On the C++ side, handle messages in the app's message loop as usual
(kind of a big topic for here).
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
On the C++ side I have lparam of type int. How should I refer to it in order to get my string?
Thanks!
|
|
|
|
|
For the ANSI string sample I showed, something like this:
const char *pANSIstring = (const char *)lParam;
For Unicode, you could change the StringToHGlobalAnsi to
StringToHGlobalUni on the C# side, and on the C++ side, something like:
const wchar_t *pUnicodestring = (const wchar_t *)lParam;
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi Mark,
The two options you suggested doesn't work: At both cases I get 'Bad Ptr' at the C++ side (I get junk and not string).
Maybe the reason is that each one of the applications (C# and C++) uses different memory space, so passing pointers from one to another is meaningless.
Or am I missing something?
Thanks a lot,
Eyal.
|
|
|
|