|
Just to clarify, I want a user to be able to print to a printer that is set up to use this print driver and have it's output be a tiff image or whatever format I choose to implement. Would something like this be possible?
|
|
|
|
|
You can print to file.. using the normal windows printer functions.
But I don't know if that is what you're looking for.
"Every rule in a world of bits and bytes can be bend or eventually be broken"
|
|
|
|
|
No, because if I am not mistaken, print to file just sends the data stream that it would send to a printer to a file.
|
|
|
|
|
It's possible, but c# was not designed to do such low level work. Besides, I think what you want already exists. Install a new local printer, chose FILE: as the port, when you get to picking the printer driver, install Generic/Generic Text. Then you can output whatever you want. You'll have to output the file format yourself so you better know the exact format of a TIFF file or what ever your going to print.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Anyone have any experience/tips on how I'd go about setting up a database with stored procedures on my Pocket PC ( it's the 2003 OS ). I know there is a SQL Server CE, but it seemed to imply I didn't need to download it if I was using .NET languages. What's the alternative ?
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
|
Anders Molin wrote:
Whats wrong with SQL-Server CE?
I don't know. The point was that the Microsoft download page for SQL Server CE seemed to state it was not the way to go when developing for .NET. I've not even installed it yet, but the question is 'do I need to' ?
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
Christian Graus wrote:
The point was that the Microsoft download page for SQL Server CE seemed to state it was not the way to go when developing for .NET.
Hmmm, interesting, I have to take a look at that.
I have mostly done CE development before .NET, but most of it is still the same
- Anders
Money talks, but all mine ever says is "Goodbye!"
ShotKeeper, my Photo Album / Organizer Application[^]
My Photos[^]
New developersite: RealDevs.Net
|
|
|
|
|
I've seen many examples on MSDN that use SQL Server CE, and the .NET Framework even has a SQL Server CE-specific ADO.NET provider. I'd say go with it; you most likely won't find a better CE database with that level of support from .NET.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I'm still trying to get this SetupDiGetDeviceInterfaceDetail function to work in C#.
I am using these definitions now:
[StructLayout(LayoutKind.Sequential)]
public class SP_DEVICE_INTERFACE_DATA
{
public uint cbSize;
public Guid InterfaceClassGuid;
public uint Flags;
public IntPtr Reserved;
}
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
public class SP_DEVICE_INTERFACE_DETAIL_DATA
{
public uint cbSize;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=1)]
public string DevicePath;
}
[StructLayout(LayoutKind.Sequential)]
public class SP_DEVINFO_DATA
{
public uint cbSize;
public Guid ClassGuid;
public uint DevInst;
public IntPtr Reserved;
}
[DllImport("setupapi.dll")]
public static extern bool SetupDiGetDeviceInterfaceDetail(
IntPtr DeviceInfoSet,
ref SP_DEVICE_INTERFACE_DATA DeviceInterfaceData,
out SP_DEVICE_INTERFACE_DETAIL_DATA DeviceInterfaceDetailData,
uint DeviceInterfaceDetailDataSize,
out uint RequiredSize,
out SP_DEVINFO_DATA DeviceInfoData);
Ok, the MSDN Library tells me this:
Using the SetupDiGetDeviceInterfaceDetail function to get details about an interface is typically a two-step process:
1. Get the required buffer size. Call SetupDiGetDeviceInterfaceDetail with a NULL DeviceInterfaceDetailData pointer, a DeviceInterfaceDetailDataSize of zero, and a valid RequiredSize parameter. In response to such a call, this function fails, GetLastError returns ERROR_INSUFFICIENT_BUFFER, and the RequiredSize parameter receives the required buffer size.
2. Allocate an appropriately sized buffer and call the function again to get the interface details.
The interface details returned by this function include a device path that can be passed to functions such as CreateFile. Do not attempt to parse the device path symbolic name. Note that the device path can be reused after the system is rebooted.
The SetupDiGetDeviceInterfaceDetail function can be used to get only the DeviceInfoData parameter. If the interface exists but the DeviceInterfaceDetailData parameter is NULL, the function fails, GetLastError returns ERROR_INSUFFICIENT_BUFFER, and the DeviceInfoData structure is filled with information about the device that exposes the interface.
Now this is what I am doing:
Win32APIfunctions.SP_DEVICE_INTERFACE_DATA devInterfaceData = new Interfaces.Win32APIfunctions.SP_DEVICE_INTERFACE_DATA();
devInterfaceData.cbSize = (uint)Marshal.SizeOf(devInterfaceData);
Win32APIfunctions.SP_DEVICE_INTERFACE_DETAIL_DATA devInterfaceDetailData = null;
Win32APIfunctions.SP_DEVINFO_DATA devInfoData = null;
uint uiRequiredSize=0;
Win32APIfunctions.SetupDiGetDeviceInterfaceDetail(NewDeviceInfoSet, ref devInterfaceData, out devInterfaceDetailData, 0, out uiRequiredSize, out devInfoData);
int iLastError = Marshal.GetLastWin32Error();
I always get errorcode 1421 ERROR_CONTROL_ID_NOT_FOUND.
It's driving my mad! Everything looks correct to me
-------------------------------------------
The light at the end of the tunnel has been switched off temporarily due to budget problems...
|
|
|
|
|
Pain_Elemental wrote:
Win32APIfunctions.SetupDiGetDeviceInterfaceDetail(NewDeviceInfoSet, ref devInterfaceData, out devInterfaceDetailData, 0, out uiRequiredSize, out devInfoData); int iLastError = Marshal.GetLastWin32Error();
Why are you checking for the last error, if you dont even know if there is one!? Test the return value of the call. That could be dirty data, or maybe you reading the number wrong...
top secret xacc-ide 0.0.1
|
|
|
|
|
Well, the only return value of interest is uiRequiredSize, but this is always 0.
By the way, I always check for last error just for debugging perpose.
-------------------------------------------
The light at the end of the tunnel has been switched off temporarily due to budget problems...
|
|
|
|
|
I forgot to set SetLastError=true at the import statement.
Now I get an other error code.
Here's my piece of code again:
Win32APIfunctions.SP_DEVICE_INTERFACE_DATA devInterfaceData = new Interfaces.Win32APIfunctions.SP_DEVICE_INTERFACE_DATA();
devInterfaceData.cbSize = (uint)Marshal.SizeOf(devInterfaceData);
Win32APIfunctions.SP_DEVICE_INTERFACE_DETAIL_DATA devInterfaceDetailData = null;
Win32APIfunctions.SP_DEVINFO_DATA devInfoData = null;
uint uiRequiredSize=0;
if(!Win32APIfunctions.SetupDiGetDeviceInterfaceDetail(NewDeviceInfoSet, ref devInterfaceData, out devInterfaceDetailData, 0, out uiRequiredSize, out devInfoData))
{
int iLastError = Marshal.GetLastWin32Error();
Win32Exception myEx = new Win32Exception();
throw new System.ApplicationException(myEx.Message, myEx.InnerException);
}
Now I get
Error code: 1784
ERROR_INVALID_USER_BUFFER: The supplied user buffer is not valid for the requested operation.
I think that possibly this could be the problem:
Win32APIfunctions.SP_DEVICE_INTERFACE_DATA devInterfaceData = new Interfaces.Win32APIfunctions.SP_DEVICE_INTERFACE_DATA();
devInterfaceData.cbSize = (uint)Marshal.SizeOf(devInterfaceData);
Am I allowed to cast to uint here?
-------------------------------------------
The light at the end of the tunnel has been switched off temporarily due to budget problems...
|
|
|
|
|
I use a PictureBox array in my project;
<br />
public PictureBox[] illustration;<br />
illustration = new PictureBox[10];<br />
...<br />
myInkPicture[IntSelectPage].illustration[i] = new System.Windows.Forms.PictureBox();<br />
...<br />
myInkPicture[IntSelectPage].illustration[i].MouseDown += new System.Windows.Forms.MouseEventHandler(myInkPicture[IntSelectPage].illustration_MouseDown);<br />
the ten PictureBoxes use the same MouseDown event handler,
<br />
public void illustration_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)<br />
{<br />
pictureBox1.Capture = true;<br />
startMoveLocation = new Point(e.X, e.Y); <br />
}<br />
I want the pictureBox1 to be the illustration[i] ,
How can I typecast the object sender to be the illustration[i] PictureBox...??
|
|
|
|
|
Hi,
In your mouse down event handler sender is the object that caused the event. In this case it will be whatever picturebox the mouse went down over. I believe that by casting sender to a picturebox you will have the picturebox that the mouse went down on aka illustration[i].
Do this with ((PictureBox)sender).Capture = true;
Karl
|
|
|
|
|
I have tried and it really works !!
Thank you very much
|
|
|
|
|
Ok guys, I've done my research and I have found great articles here that really gave me a kickstart on updating the UI by calling Invoke on the main thread from a worker thread. But I'm trying to apply this knowledge to an application which uses delegates to perform asynchronous calls without sucess. Here is the interesting situation:
I have a delegate declared outside the windows form class resposible for the UI updates
public delegate void delegateUpdateStatus(string msg);
then there is the delegate which I use for the asynchronous calls (inside the form class)
public delegate void delegateAsynch(parameters here);
in the click event of a button I create an instance of the asynchronous delegate
delegateAsynch myAsynchDelegate = new delegateAsynch(target function)
then I use the BeginInvoke method on the asynchronous delegate and works perfectly great. Now I have decided to update the UI with a label giving feedback of the progress. That's where the first delegate declared above comes in. The problem is that in the target function I make a call to Invoke like:
Invoke(new delegateUpdateStatus(updateStatus), new object[] {"Hello"});
or BeginInvoke(new delegateUpdateStatus(updateStatus), new object[] {"Hello"});
and the application goes to a zombie state with any of those statements without even modifying the UI (I tried only one of those statements on different runs). I have carefully placed breakpoints to see where it is hanging but after any of those lines is executed no other instruction is called, not even the method (updateStatus) the delegate is supposed to call. It is worth noting that Intellisense really knows that Invoke or BeginInvoke comes from Control. I have slapped against a wall, please help!
|
|
|
|
|
Make sure you check Control.InvokeRequired before calling Control.Invoke or Control.BeginInvoke to determine if invoking is even necessary. If it is not required, just call updateStatus directly. Since yo're using async invocation, it should be required but it was just a thought. I do this quite a bit in our enterprise app and have never had a problem.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thank you Stewart for your reply. After reading your post I put the call to the update delagate in an if statement with the condition lblStatus.InvokeRequired . To my surprise the InvokeRequired property always returned false. How can this be if before using asynchronous delegates the UI freezed. Now that I'm using async invocations the UI is responsive as it should be. Also, a direct call to the updateStatus method does not update the UI, although the program does not enter a zombie state. Any ideas!? The fact that the lblStatus.InvokeRequired returned false got me confused with async invocation using delegates.
|
|
|
|
|
I have a search for a Client/Server Framework Developer.
You will use C#, XP, agile, and paired programming in a large shop in a suburb of Cleveland.
Please contact me if you are interested.
Thanks!
Dick Ellison
ellisor@aol.com
|
|
|
|
|
|
When you create a Windows forms project in VS .NET 2003 you get a file called App.ico, right? So I started drawing in it to get my own icon. I then took the main window and went to the Icon property. I pressed the button there and chose the App.ico file in the project folder. This doesnt work. The exe file created has the standard icon and so does the program when it starts. If I open the ico file in VS it looks just like I drew it.
I used the same icon for a contextmenu and it works there. When I minimize the program to the system tray I have the correct icon there but the program doesnt.
By the way, an *.ico file should look like the icon itself when I look at it in an explorer window, right?
Thanks
|
|
|
|
|
Hi,
I am not sure if this is your problem or not. Icon files can have multiple versions of the icon, most commonly a (16x16 and 32x32) when the icon is being used the appropriate version is used. The default icon has both 16x16 and 32x32 versions, if you only changed one of them there will be some situation where the one you didn't change is used.
To change the other version open the icon in the editor. Right click in the editing window (but not on the icon) and in the list that appears there will be "Current Icon Image Types".
Hope this helps,
Karl
Karl Baum
CEO of KGB Technologies
Specializing in custom software development.
|
|
|
|
|
It s a bug in VS, that doesnt refresh it resources. Just remove the file (not delete) so VS can know something happened to it (just build or something to create an error), then just re-add it.
top secret xacc-ide 0.0.1
|
|
|
|
|
I managed to get both the problems you described. Your solutions solved it. Thanks!
|
|
|
|