|
I tried all of that before I posted, and tried it again after you posted, and still, nothing. I tried dwEffects=0, dwEffects=CFE_PROTECTED, not setting dwEffects, etc. Nothing has worked. Like I said, the call to DefWndProc is returning a non zero value, so it is working, just not how I want it to. There has to be something I am missing somewhere... I am going to list all my constants, structure, etc, and perhaps someone can figure out what is going on. FYI, I have also tried the API call and it does the same thing.
[StructLayout(LayoutKind.Sequential)]
private struct CHARFORMAT2
{
public int cbSize;
public int dwMask;
public int dwEffects;
public int yHeight;
public int yOffset;
public int crTextColor;
public byte bCharSet;
public byte bPitchAndFamily;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=32)]
public string szFaceName;
public int wWeight;
public int sSpacing;
public int crBackColor;
public int lcid;
public int dwReserved;
public int sStyle;
public int wKerning;
public byte bUnderlineType;
public byte bAnimation;
public byte bRevAuthor;
public byte bReserved1;
}//struct charformat2
//constants
EM_SETCHARFORMAT=0x444;
CFM_BACKCOLOR=0x4000000;
CFM_COLOR=0x40000000;
SCF_SELECTION=0x1;
//Call to format, tried CFM_BACKCOLOR and CFM_BACKCOLOR|CFM_COLOR, etc,
// only forecolor changes
CHARFORMAT2 cf2=new CHARFORMAT2();
cf2.dwMask=CFM_BACKCOLOR;
cf2.cbSize=Marshal.SizeOf(cf2);
cf2.crBackColor=ColorTranslator.ToWin32(Color.Red);
IntPtr lParam=Marshal.AllocCoTaskMem(Marshal.SizeOf(cf2));
Marshal.StructureToPtr(cf2, lParam, false);
Message msg=Message.Create(this.Handle, EM_SETCHARFORMAT, (IntPtr)SCF_SELECTION, lParam);
DefWndProc(ref msg);
Marshal.FreeCoTaskMem(lParam);
|
|
|
|
|
I have 3 docking panel controls in a form.
Left Dock is a toolbox.
Center Dock has 2 children, one child is another panel with a bitmap on it. And the other is a panel for displaying a bitmap font for a corresponding KeyPress value.
Right Dock Panel has a textbox child.
When I use the Center.KeyPress mapped it a function it works correctly and types out the appropriate font, but if I click on the other child within the Center Dock, The Center dock(parent) loses focus and the KeyPress event is not firing.
I tried several things to regain focus: like overriding several functions to force Center.Focus() so the input would still type out. I am at a total loss on what to do now. The only way the KeyPress works again is if I click OUT of the Center Dock and then click back in.
Any suggestions would be great.
|
|
|
|
|
You could try mapping the child controls KeyPress event to the Center Dock's KeyPress event so if a key is pressed on the child control the code in your Center Dock's KeyPress event handler will be called.
- Aaron
|
|
|
|
|
Is it possible to create an abstract class with multiple constructors, and the constructor that is called is control by the class that inherits from it?
As an example, I have these two classes:
public abstract class MyAbs
{
protected MyAbs(){}
protected MyAbs(string foo){}
}
}
public sealed class Something : MyAbs
{
public Something(){}
public Something(string foo){}
}
If an instance of the "Something" class is created using the constructor that takes a string parameter I would like to constructor the base "MyAbs" class using that value. Is this possible?
|
|
|
|
|
public Something( string foo ) : base( foo ) {}
|
|
|
|
|
Thanks for the reply it works exactly as I needed
Whilst on this subject is it possible to construct the abstract class with a string that is created within the "Something" class constructor?
|
|
|
|
|
No. The constructor of the abstract class is executed before the code in the constructor of the inheriting class.
---
b { font-weight: normal; }
|
|
|
|
|
I have been using threadpool to run a thread, and the worker thread need an integer as argument:
<br />
private void someMainThread() {<br />
int ordernum = 10;<br />
ThreadPool.QueueUserWorkItem(new WaitCallback(chkOrderstart), ordernum);<br />
}<br />
<br />
private void chkOrderstart(Object stateinfo) {<br />
int orderNum = (Int32)stateinfo;
...<br />
}<br />
I tried the above code and it is giving me:
C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Microsoft.Common.targets(2071,9): error MSB3113: Could not find file 'Microsoft.Windows.CommonLanguageRuntime, Version=2.0.50727.0'.
Done building project "VWStressTester.csproj" -- FAILED.
Pleas help
|
|
|
|
|
wow. uh, that seems like an install problem. your code *looks* correct (C# will 'BOX' the int as an object). try casting 'stateinfo' to int instead of Int32.
Did you have beta versions of VS2005 installed previously?
|
|
|
|
|
Hi
I need to print the report which I am creating using crystal reports. I am getting the list of attached printers and displaying in a drop down list as follows:
for( int i = 0; i < PrinterSettings.InstalledPrinters.Count; i++ )
{
string printerName = PrinterSettings.InstalledPrinters[i].ToString();
ddlPrinters.Items.Add( printerName );
}
This particular piece of code displays the list of printers on server side. I instead want the list of printers on client side. Can someone please suggest how to do that?
Thanks in advance
|
|
|
|
|
I take it this is a WEB application and not Windows Forms???
If so, then you can't do this in your C# code since the server-side has absolutely zero access to the client. You'll have to use client-side JavaScript to do something like this.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
In Javascript, I know window.print() is used but it prints the complete page.
1. Is their anyway in javascript to get the printer names on client machine ?
1. What do we do in javascript to print only the part of page and not the complete page ?
Thanks
|
|
|
|
|
I have no idea.
In theory, JavaScript running in a browser has no access to the list of installed printers.
But, you'd have to ask this in the Web Development forum for a better answer.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
So, you got question number one, and question number one?
For the first question number one:
No. There is absolutely no way that you can det the printer names using javascript.
For the second question number one:
You can't print a part of a page using javascript. You could take the contents of a part of a page, put it in a page in a new window, and print it.
---
b { font-weight: normal; }
|
|
|
|
|
Thanks
That is what I am doing now. Displaying a part of page that I want to print on a new page and then printing.
|
|
|
|
|
I can create a pointer array, such as:
IntPtr[] openWindows = new IntPtr[100];
But i am unable to store windows hWnds. When i do the following:
openWindows[0] = hWndOfSomeWindow;
And read it back:
Debug.WriteLine(openWindows[0]);
All i get is '0', not the window handle ID. Can someone point our my wrongness here?
|
|
|
|
|
From the deaf silence to my post i assumed that i was doing something foolishly wrong and so i started doing more tests. I finally found that the problem was the incorrect use of an index variable for the IntPtr array. It was not incrementing and so the pointers were all being saved to a single array location. Common error.
|
|
|
|
|
I am trying to read a PDF file so I can convert its data to a readable format that I can then load into a SQL data table. I am not remoting, and I am getting the following error....
Additional information: BinaryFormatter Version incompatibility. Expected Version 1.0. Received Version 825309752.540554042.
My code looks like this....
using System;
using System.IO;
using System.Collections;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Serialization;
public class App
{
[STAThread]
static void Main()
{
Deserialize();
}
static void Deserialize()
{
// Declare the hashtable reference.
Hashtable myPDFdata= null;
// Open the file containing the data that you want to deserialize.
FileStream fs = new FileStream("MyPDF.pdf", FileMode.Open);
try
{
BinaryFormatter formatter = new BinaryFormatter();
// Deserialize the hashtable from the file and
// assign the reference to the local variable.
myPDFdata = (Hashtable) formatter.Deserialize(fs);
}
catch (SerializationException e)
{
Console.WriteLine("Failed to deserialize. Reason: " + e.Message);
throw;
}
finally
{
fs.Close();
}
// To prove that the table deserialized correctly,
// display the key/value pairs.
foreach (DictionaryEntry de in myPDFdata)
{
Console.WriteLine("{0}myPDFdata.", de.Key, de.Value); }
}
}
Or is there a better way of doing this????
Thanks!
Curt
|
|
|
|
|
Guys I'm at a loss!
I don't want wait cursor to be displayed in my app at all. How can I suppress it totally or change the picture of the WaitCursor to Arrow (default) cursor - so that anytime wait cursor is invoked it would show the arrow, hence show no change.
And why doesn't Cursor.Current = Cursors.Arrow; work. It's supposed to set the current cursor, but it does nothing!
Any help is appreciated!
|
|
|
|
|
That all depends on what's causing the wait cursor. If it's a web browser control on your form, then no, you can't stop the wait cursor from happening. The browser control is what' setting the cursor to Busy. So long as the cursor is over that control, it'll show up Busy.
Changing the image of the cursor, as in your workaround, would require changing the image system-wide. A practice I greatly discourage.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
"Changing the image of the cursor, as in your workaround, would require changing the image system-wide. A practice I greatly discourage."
I agree. That would be sloppy.
Yes, the WebBrowser control is causing it to fire the cursor change, so how can I prevent that. Can I derive from the WebBrowser control and change it there? There's got to be a way to do this!!!!
|
|
|
|
|
peshkunta wrote: Yes, the WebBrowser control is causing it to fire the cursor change, so how can I prevent that.
There's no way to prevent it. You could create you own class from the WebBrowser class, but you still wouldn't be able to prevent the cursor from changing because it's not the class code that's changing the cursor. It's the Internet Explorer object code that's doing it, and there's no way you can change that.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
The WebBrowser object is a control. Why couldn't I make a custom web browser control???
|
|
|
|
|
peshkunta wrote: The WebBrowser object is a control. Why couldn't I make a custom web browser control???
You could, but doing so would require writing your own browser. You could largely bypass doing so by using the firefox codebase, but would inject the GPL into your code as a result.
|
|
|
|
|
The WebBrowser class in .NET is a WRAPPER for the IE COM object.
In order to supply this functionality, you'd have to write your own web browser class, supplying all the HTML rendering code, but does not wrap the IE COM control, which is entirely possible.
Just creating a new class, inheriting from the existing WebBrowser class, will not allow you to do what you want, since you're inheriting from the WebBrowser class, you're also inheriting the COM object that it wraps.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|