|
Hi friends :
How can I change "zoom" value in print preview dialog ?
I want to change its value from "Autosize" to "100%".
thank you in advance.
|
|
|
|
|
Try
int PreferredZoomValue = 75;<br />
PrintPreviewDialog dgl = new PrintPreviewDialog();<br />
dgl.PrintPreviewControl.Zoom = PreferredZoomValue / 100f;
|
|
|
|
|
it is true with a little revision :
int PreferredZoomValue = 100;
thank you
|
|
|
|
|
Hi friends :
How can I maximize print preview dialog ? I used the following code but it doesn't maximize completely?
ppdialog.Width = Screen.PrimaryScreen.WorkingArea.Width;
ppdialog.Height = Screen.PrimaryScreen.WorkingArea.Height;
thank you in advance.
|
|
|
|
|
hi there;
i want to embed an application in my form panel ;
i tried this code
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace show_exe
{
public partial class form2 : Form
{
#region Methods/Consts for Embedding a Window
[DllImport("user32.dll", EntryPoint = "GetWindowThreadProcessId", SetLastError = true,
CharSet = CharSet.Unicode, ExactSpelling = true,
CallingConvention = CallingConvention.StdCall)]
private static extern long GetWindowThreadProcessId(long hWnd, long lpdwProcessId);
[DllImport("user32.dll", SetLastError = true)]
private static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll", SetLastError = true)]
private static extern long SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
[DllImport("user32.dll", EntryPoint = "GetWindowLongA", SetLastError = true)]
private static extern long GetWindowLong(IntPtr hwnd, int nIndex);
[DllImport("user32.dll")]
static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);
[DllImport("user32.dll", SetLastError = true)]
private static extern long SetWindowPos(IntPtr hwnd, long hWndInsertAfter, long x, long y, long cx, long cy, long wFlags);
[DllImport("user32.dll", SetLastError = true)]
private static extern bool MoveWindow(IntPtr hwnd, int x, int y, int cx, int cy, bool repaint);
[DllImport("user32.dll", EntryPoint = "PostMessageA", SetLastError = true)]
private static extern bool PostMessage(IntPtr hwnd, uint Msg, int wParam, int lParam);
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
static extern bool ShowWindow(IntPtr hWnd, ShowWindowCommands nCmdShow);
[DllImport("user32.dll", EntryPoint = "SetWindowPos")]
public static extern IntPtr SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int x, int Y, int cx, int cy, int wFlags);
public enum ShowWindowCommands
{
Hide = 0,
Show = 5,
Minimize = 6,
Restore = 9
}
private const int SWP_NOOWNERZORDER = 0x200;
private const int SWP_NOREDRAW = 0x8;
private const int SWP_NOZORDER = 0x4;
private const int SWP_SHOWWINDOW = 0x0040;
private const int WS_EX_MDICHILD = 0x40;
private const int SWP_FRAMECHANGED = 0x20;
private const int SWP_NOACTIVATE = 0x10;
private const int SWP_ASYNCWINDOWPOS = 0x4000;
private const int SWP_NOMOVE = 0x2;
private const int SWP_NOSIZE = 0x1;
private const int GWL_STYLE = (-16);
private const int WS_VISIBLE = 0x10000000;
private const int WM_CLOSE = 0x10;
private const int WS_CHILD = 0x40000000;
private const int WS_MAXIMIZE = 0x01000000;
#endregion
#region Variables
private IntPtr gpsHandle;
private Process gpsProcess = null;
private ProcessStartInfo gpsPSI = new ProcessStartInfo();
#endregion
private void SetupGPSPanel()
{
this.gpsPanel.Location = new Point(120, 50);
this.gpsPanel.Size = new Size(this.Size.Width-200 , this.Size.Height-200 );
gpsPSI.FileName = "notepad.exe";
gpsProcess = System.Diagnostics.Process.Start(gpsPSI);
gpsProcess.WaitForInputIdle();
gpsHandle = gpsProcess.MainWindowHandle;
SetParent(gpsHandle, this.gpsPanel.Handle);
SetWindowLong(gpsHandle, GWL_STYLE, WS_VISIBLE + WS_MAXIMIZE);
MoveWindow(gpsHandle, this.gpsPanel.Location.X,this.gpsPanel.Location.Y, this.gpsPanel.Width, this.gpsPanel.Height, true);
ShowWindow(gpsHandle, ShowWindowCommands.Show);
SetWindowPos(gpsHandle, 0, 0, 0, this.gpsPanel.Bounds.Width, this.gpsPanel.Bounds.Height, SWP_NOZORDER | SWP_SHOWWINDOW);
}
public form2()
{
InitializeComponent();
}
private void form2_Load(object sender, EventArgs e)
{
SetupGPSPanel();
}
}
}
this code works for notepad application but not for other apps
like photoshop ,dvbviewer , winword
why ???
i hope some body help
thanx in advance
|
|
|
|
|
I'm surprised that even NotePad will work inside a Panel in a Windows Form !
I think the following are relevant to your concerns:
on CP, 2004: [^]
on StackOverFlow, 2011: [^]
I would expect "major" non MS applications, like PhotoShop, to never run inside a WinForm, but, I could be wrong.
I think, in general, it is a very bad idea to ever use an instance of another application inside a WinForms app. You are not going to be able to interact with the other application unless you do some tricks like writing a file to a folder that your WinForms app has set a FileWatcher to fire a callback to you when the folder has changed. Back in the stone-age, in the era of COM, SendKeys was a way for VB to interact with other applications, and it was a royal pain in the arse to use (I hope it's extinct, by now).
MS "hands you" standard techniques for automation with the MS Office tools, and IE, and other companies may offer you some sort of API for their software (even hardware) so you can interact with it indirectly. And, of course, you can have a WPF app in a WinForm, and the reverse.
But, I invite you to consider whether it's really wise to struggle to get Application "X" working inside a WinForm.
bill
Google CEO, Erich Schmidt: "I keep asking for a product called Serendipity. This product would have access to everything ever written or recorded, know everything the user ever worked on and saved to his or her personal hard drive, and know a whole lot about the user's tastes, friends and predilections." 2004, USA Today interview
|
|
|
|
|
ahaaaa i got what u meant
but ...!
i think of this way because i want to display my tv satellite channels in my form.... so i think i could call the exe of the sattelite application ( DVB viewer TE ) to apanel in my form >>
i dont know how to do that ....i guess that idea was the easiest
could u give a better ,simple idea ..
i had read article here about capturing tv
but i dont think that what i need
i want just to view tv and move channels up and down
thanx i lot for ur answer
waiting for clues
|
|
|
|
|
Hi,
I have WinForm application.
I am trying to display a value from MySQL. The field type is time and it's NOT null.
I am using this code:
lblStartTime.Text = Convert.ToDateTime(sql_reader["start_time"]).ToString("HH:mm");
but getting this error message:
Unable to cast object of type 'System.TimeSpan' to type 'System.IConvertible'.
Please Help..
Technology News @ www.JassimRahma.com
|
|
|
|
|
Maybe this[^] could help you.
|
|
|
|
|
lblStartTime.Text = Convert.ToDateTime(sql_reader["start_time"]).ToString("HH:mm");
OK, let's break this down into its constituent parts:
sql_reader["start_time"] returns a Time value.
.ToString("HH:mm"); converts that to a string in the form HH:mm.
Convert.ToDateTime converts that string into a DateTime value.
lblStartTime.Text = which you than try to assign to a Text field.
Veni, vidi, abiit domum
|
|
|
|
|
I tried this:
lblStartTime.Text = sql_reader["start_time"].ToString("HH:mm");
but got:
Error 28 No overload for method 'ToString' takes 1 arguments
Technology News @ www.JassimRahma.com
|
|
|
|
|
this is my database structure for your info:
CREATE TABLE `job_orders` (
`job_order_id` int(11) NOT NULL AUTO_INCREMENT,
`customer_id` int(11) DEFAULT NULL,
`cleaner_id` int(11) DEFAULT NULL,
`job_order_status` int(255) DEFAULT '1' COMMENT 'New, Cancelled, Completed, Payment',
`is_cancelled` bit(1) DEFAULT b'0',
`job_order_date` date DEFAULT NULL,
`start_time` time DEFAULT NULL,
`end_time` time DEFAULT NULL,
`job_order_note` text,
`created_date` datetime DEFAULT NULL,
`created_user` int(11) DEFAULT NULL,
PRIMARY KEY (`job_order_id`),
UNIQUE KEY `idx_job_orders_job_order_id` (`job_order_id`),
KEY `idx_job_orders_customer_id` (`customer_id`),
KEY `idx_job_orders_cleaner_id` (`cleaner_id`),
KEY `idx_job_orders_job_order_status` (`job_order_status`),
KEY `idx_job_orders_is_cancelled` (`is_cancelled`),
KEY `idx_job_orders_job_order_date` (`job_order_date`),
KEY `idx_job_orders_start_time` (`start_time`),
KEY `idx_job_orders_end_time` (`end_time`),
KEY `idx_job_orders_created_date` (`created_date`),
KEY `idx_job_orders_created_user` (`created_user`)
) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8;
Technology News @ www.JassimRahma.com
|
|
|
|
|
What class type is returned from the sql_reader["start_time"] property? Check the documentation to see if it has a ToString method, and if so what is the syntax? You cannot write code like this and just assume it will work, you need to ensure you are using valid properties and methods.
Veni, vidi, abiit domum
|
|
|
|
|
Jassim Rahma wrote: Unable to cast object of type 'System.TimeSpan' to type 'System.IConvertible'.
sql_reader["start_time"] is returning a TimeSpan[^]. You cannot convert a TimeSpan to a DateTime , which is why the call to Convert.ToDateTime is failing.
If your time value is always less than 24 hours, you could use:
lblStartTime.Text = ((TimeSpan)sql_reader["start_time"]).ToString("hh\\:mm");
However, note that the hh format specifier only includes "the number of whole hours in the time interval that is not counted as part of its day component":
http://msdn.microsoft.com/en-us/library/ee372287.aspx[^]
If your time values could exceed 24 hours, you would need to format the value yourself:
private static string FormatTime(TimeSpan time)
{
return string.Format("{0:##00}.{1:00}", time.TotalHours, time.Minutes);
}
lblStartTime.Text = FormatTime((TimeSpan)sql_reader["start_time"]);
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Everybody,
i need to implement something that I need to know which url a current user is acessing. I already have a IE, Chrome and Firefox implementation, but I need to find shomething that works fine in Safari and Opera.
Somebody can help me to solve this?
Cheers,
Túlio Cruz.
|
|
|
|
|
Why write a bunch of code when any off-the-shelf proxy server will do this for you, and without having to write speerate support for every possible browser.
|
|
|
|
|
One reason not to use a proxy server is that the browser must be configured to work with it, and that's a hassle for the user.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Compared to the hassle of individually supporting many browsers, it's a very small one.
We also don't know anything of the environment to which this app is being targeted.
|
|
|
|
|
I am a beginner to C# while reading i came a cross Cesign Patterns So Can anyone please tell what is this Design Pattern ?
- factory
- Singleton
- Chain of Responsibility
How they help in development of Applications ?
|
|
|
|
|
It's impossible to provide sufficient detail to your question in a forum like this. There are plenty of references on the internet that will explain, the purpose of design patterns, and the different types that may be used. There are also books that cover the subject in full detail.
Veni, vidi, abiit domum
|
|
|
|
|
|
You can buy a book on design patterns and go through them.
|
|
|
|
|
Capturing a wealth of experience about the design of object-oriented software, four top-notch designers present a catalog of simple and succinct solutions to commonly occurring design problems. dofactoy[^] shows C# and VB.NET sample code of any GoF (Gang of Four: Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides) pattern.
Cheers,
Jani Giannoudis
Meerazo.com - Resource Sharing Made Easy | Co-founder
|
|
|
|
|
Design patterns are a dime a dozen. Since you are a "beginner", then I would focus on the fundamentals first, and worry about patterns later.
Good luck.
|
|
|
|
|
|