|
NiNa03 wrote:
i need help with a program in c#...can anyone out there help me please?!?
Maybe... But we could help you faster if you post your specific problem, with details.
ORACLE One Real A$#h%le Called Lary Ellison
|
|
|
|
|
Does anyone have a FourCC class wrapper available? I'm new to C# so I'm not sure if I'm doing something wrong. I'd basically like to have a number of predefined types that I can use within my class, I've currently tried the following:
<br />
namespace MyNamespace<br />
{<br />
public class MyClass<br />
{<br />
private static const FourCC TEST_FOURCC( 'T', 'E', 'S', 'T' );<br />
}<br />
}<br />
Where 'FourCC' is a struct I've defined which accepts four values. The compiler moans at this though (cannot specify constructor arguments in declaration).
As I'm new to C# is there something I've missed? It'd be great if I could just define them as an enum or uints (I've tried "private static uint TEST_FOURCC = 'TEST';" but it moans about too many characters in literal), I've also tried looking for a standard version in the framework but no luck.
Thanks,
n!
|
|
|
|
|
nfactorial wrote:
private static const FourCC TEST_FOURCC( 'T', 'E', 'S', 'T' );
static const FourCC TEST_FOURCC = new FourCC( 'T', 'E', 'S', 'T' );
<a TITLE="See my user info" href=http:
|
|
|
|
|
damn, so near and yet so far
Thanks,
n!
|
|
|
|
|
Hi!
I'm having some problems with flickering while resizing a Form!
I have a Form with two Panels and a Splitter. On each panel is a image drawn. Problem is when resizing the Form the images flicker like hell. Real annoying
Anyway, I've tried to use the SetStyle (i.e. setting DoubleBuffering to true, UserPaint to true, and AllPaintingInWmPaint to true) method in the control class but that doesn't seem to work!!
What do you recommend?
|
|
|
|
|
I'm not sure that this would really be desirable for other reasons, but you could try the following:
Don't do any painting inside the normal paint handler. Instead, create a bitmap (which you'll need to resize along with the window size). Set that bitmap as the background image. Then, redraw the bitmap and call Invalidate() when the content changes. The rest of the time, the window should handle redrawing from the bitmap and avoid some of the flickering.
John
"We want to be alone when we hear too many words and we feel alone when it has been a while since anyone has spoken to us." Paul David Tripp -- War of Words
|
|
|
|
|
Guys,
I've seen this type of question before but my search did not turn up anything.
Here is the C# API definition:
[DllImport"user32.dll",EntryPoint="SendMessage",ExactSpelling=false,SetLastError=true)]
public static extern int SendMessage(int hwnd,int wMsg,int wParam,int lParam);
All the places where I call this function I use simple integers. But now I have a spot where I want to call this function and for lParam I need to pass a pointer to a null-terminated string. How do I do that?
|
|
|
|
|
|
For recieving a string:
[StructLayout(LayoutKind.Sequential, CharSet=CharSet.Auto)]
public struct STRINGBUFFER
{
[MarshalAs(UnmanagedType.ByValTStr, SizeConst=512)]
public string szText;
}
[DllImport"user32.dll",EntryPoint="SendMessage", ExactSpelling=false,
SetLastError=true,<font color=red>CharSet=CharSet.Auto</font>)]
public static extern int SendMessage(<font color=red>IntPtr</font> hwnd,int wMsg,int wParam,<font color=red>out STRINGBUFFER lParam</font>);
For passing a string out:
[DllImport"user32.dll",EntryPoint="SendMessage",ExactSpelling=false,
SetLastError=true,<font color=red> CharSet=CharSet.Auto</font>)]
public static extern int SendMessage(<font color=red>IntPtr</font> hwnd,int wMsg,int wParam,<font color=red>text lParam</font>);
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
Thanks J,
I was sort of looking for a way to do it without having to change the import. I'm able to do what I need by using "..., String lParam)". But I am wondering if there was some way I could still use the "..., int lParam)" definition and do something special in the calling statment.
|
|
|
|
|
albean wrote:
I was sort of looking for a way to do it without having to change the import.
Well, I don't know of a way, short of using pointers (which I think is more time-consuming). But you can have multiple defs for the same API with the same name. All you have to do is copy the original SendMessage each time and change the lParam parameter's data type.
"Blessed are the peacemakers, for they shall be called sons of God." - Jesus
"You must be the change you wish to see in the world." - Mahatma Gandhi
|
|
|
|
|
I've got two applications, one written in C# and the other is WinBatch (don't ask). In regular C++ it was easy for the WinBatch app to simply PostMessage(..) to the C++ app and using a message map, I could set a function to get executed upon receiving the message.
In C# I'm having difficulty finding a way to receive and map the message received from a non-.Net based app.
Any insight would be greatly appreciated.
|
|
|
|
|
I'm not sure what stage you are at but here is how I handle messages:
<br />
<br />
<br />
protected override void WndProc( ref Message m )<br />
{<br />
const int UWM_HERE_I_AM = 0x1234;<br />
<br />
switch( m.Msg )<br />
{ <br />
case UWM_HERE_I_AM:<br />
m.Result = OnHereIAm( m.WParam, m.LParam );<br />
return;<br />
}<br />
<br />
base.WndProc( ref m );<br />
}<br />
<br />
<br />
|
|
|
|
|
I hadn't even thought of overriding the WndProc... doh!!
Thanks!!!
|
|
|
|
|
I want to place a second Icon on the Title Region of a Form.
How?
|
|
|
|
|
you can override the Onpaint method and do whatever you like. Requires lot of work, after whatever you do call the base.Onpaint with the same arguments;
|
|
|
|
|
My friend's computer is reporting this error when trying to fill a DataSet. All was working fine until he installed the sample PetShop project from Microsoft. Anybody have a CLUE on HOW to fix? HE can't run ANY projects that connect to SQL.
[COLOR=red]Server Error in '/DataListDemo' Application.
--------------------------------------------------------------------------------
'ResourcePool' is not supported on the current platform.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.PlatformNotSupportedException: 'ResourcePool' is not supported on the current platform.
Source Error:
Line 77: SqlDataAdapter da = new SqlDataAdapter("Select * From Titles", conn);
Line 78: DataSet ds = new DataSet();
Line 79: da.Fill(ds, "title_record");
Line 80: DataList1.DataSource = ds;
Line 81: DataList1.DataBind();
[/COLOR]
|
|
|
|
|
See if you have any open connections to the sql server when you do that and check The connectionstring in the SqlConnection object! in the code i usually write
DataList1.DataSource = ds.Tables["title_record"]
but i think is ok either way!
|
|
|
|
|
Hi everyone. (this is my first post to this board, so please forgive me if it doesn't look right).
I am new to c# and i am wondering if someone can help me write a for loop to return all the fields and data in a database. This is the code and it works 100%, but i want it to query the table fields and data dynamically instead of what i have.
<br />
using System;<br />
using Microsoft.Data.Odbc;<br />
using Console = System.Console;<br />
<br />
namespace practice<br />
{<br />
public class dbconnection<br />
{<br />
public void swdata()<br />
{<br />
string msg;<br />
string native;<br />
string src;<br />
string sql;<br />
<br />
try<br />
{<br />
string _db = "DRIVER={MySQL ODBC 3.51 Driver};" +<br />
"SERVER=<server ip>;DATABASE=<db>;" +<br />
"UID=<user>;PASSWORD=<pwd>;" +<br />
"OPTION=512";<br />
OdbcConnection dbconnect = new OdbcConnection(_db);<br />
dbconnect.Open();<br />
<br />
OdbcCommand my_cmd = new OdbcCommand("",dbconnect);<br />
<br />
my_cmd.CommandText = "SELECT * FROM swdata_o";<br />
OdbcDataReader my_dr;<br />
my_dr = my_cmd.ExecuteReader();<br />
<br />
while(my_dr.Read())<br />
{<br />
Console.WriteLine(my_dr.GetInt32(0) + "," + my_dr.GetString(1)<br />
+ "," + my_dr.GetString(2));<br />
}<br />
dbconnect.Close();<br />
}<br />
<br />
catch(OdbcException odbcCon)<br />
{<br />
for(int i=0;i<odbcCon.Errors.Count;i++)<br />
{<br />
msg=odbcCon.Errors[i].Message;<br />
native=odbcCon.Errors[i].NativeError.ToString();<br />
src=odbcCon.Errors[i].Source;<br />
sql=odbcCon.Errors[i].SQLState;<br />
}<br />
}<br />
}<br />
}<br />
<br />
public class open<br />
{<br />
public static void Main(String[] args)<br />
{<br />
dbconnection dbcon = new dbconnection();<br />
dbcon.swdata();<br />
}<br />
}<br />
<br />
}<br />
Thanks for your help.
|
|
|
|
|
I found my answer...
while(my_dr.Read())<br />
{<br />
for(int i=0;i<my_dr.FieldCount;i++)<br />
{<br />
output=output + my_dr.GetValue(i) + ",";<br />
}<br />
}<br />
Console.WriteLine(output + "\r");
|
|
|
|
|
Why do you need to use pointers ?
There is no reason not to use but just wondering....
Doing something is better than doing nothing. So ... Move !
|
|
|
|
|
The reason why i asked you that question was that here is for C#. So you shouldn't need to use pointers while you can do what you want to do without using pointers. Anyway. as i said, just wondered
Doing something is better than doing nothing. So ... Move !
|
|
|
|
|
yes i guess that you know
I have never coded in Managed C ++ so far, but my first programming experience had begun with C and C ++ ( Borland versions ). But after meeting C# i really stopped using pointers. But that's true that i still use interop. In my opinion, to stop its usage is almost impossible.
I would like to help you about your question but as i said i have no so much knowledge about Managed C ++. I hope someone helps you.
Take care,
cheers,
Doing something is better than doing nothing. So ... Move !
|
|
|
|
|
If I have the C code:
beEncodeChunk(HBE_STREAM hbeStream, DWORD nSamples, PSHORT pSamples, PBYTE pOutput, PDWORD pdwOutput);
can I just use ...(..., short[] Samples, ...)
or do I need pSamples to be an IntPtr?
If you want to check out the simple code (a wav -> mp3 encoder) it's located at http://www.geocities.com/grv575/encode.zip
I don't see what's wrong besides maybe the gc moving the managed arrays around if that's what causing the encode method to fail.
|
|
|
|
|
Hi,
To pass unknown length arrays as parameters is not allowed in C#. You have to inform the length of it to the function and use something like below,
[MarshalAs(UnmanagedType.ByValArray, SizeConst=TheLengthOfArray] ..... your function declaration ( ..., byte [] Samples,.... )
But if the length of the array has not a constant value then you need to find the address of your byte array and then use that address to pass to your function
cheers,
Doing something is better than doing nothing. So ... Move !
|
|
|
|