|
Vestras wrote: Gives me wrong X and Y locations
Then you did something wrong. Learn to debug, i.e. observe the details, formulate a hypothesis, check its correctness, and act on it.
When wrong, try again.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Is it possible to get a copy of your syntax coloring control?
Everything makes sense in someone's mind
|
|
|
|
|
I would really like to take a look at your source if you could post it or send me an email i would really appreciate it.
|
|
|
|
|
I'm passing an array of structs to an unmanaged method and just want to make sure that what I'm doing is correct.
Let's assume I have a struct defined as
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)]
public struct MyStruct
{
public MyStruct(string Name, uint Index, MyEnum flag)
{
}
[MarshalAs(UnmanagedType.LPTStr)]
public string mName;
public uint sIndex;
[MarshalAs(UnmanagedType.U4)]
public MyEnum mflag;
}
where MyEnum is some enum deriving from uint.
The calling code creates an array of these structs like this:
MyStruct [] structs =
{
new MyStruct("BEN", 0, MyEnum.FIRST),
new MyStruct("VAL", 1, MyEnum.FOURTH),
new MyStruct("ROG", 2, MyEnum.SECOND)
};
I then pass this array to the managed function which looks like this:
public static extern int SetMyStructs([MarshalAs(UnmanagedType.LPArray)] MyStruct [] structs)
which is supposed to map to the unmanaged function of:
int SetMyStructs(MyStruct * structs)
SetMyStructs is returning values indicating that the function is not executing correctly. Is passing an array of structs containing strings and integers possible and if so am I using the correct marshalling attributes? I just want to eliminate this array of structs as a possible reason for the failing function.
|
|
|
|
|
I have a ToolStripTextBox, I'd like to customize such that when there's no text in it, it draws some background text, in different color that's not editable. Once the user starts typing this goes away. The OnPaint method doesn't cut it, further looking shows that the ToolStripTextBox apparently hosts an internal TextBox control. The ToolStripTextBox.Paint handler (unsurprisingly) does nothing. The docs for the TextBox class claim that the Paint handler is not to be used. Is it not possible to do this in .Net?
|
|
|
|
|
Not that it helps you, but someone asked pretty much the same question on MSDN[^] in 2005.
He's still waiting for an answer!
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Sigh. What a bunch of dolts. I have the nasty suspicion that I'll have to resort to creating my own custom ToolStrip control and create a custom TextBox with WM message hooks to defeat the idiocy of Redmond's brain dead developers.
This was actually relatively *EASY* to do in MFC. Double fail for .Net.
|
|
|
|
|
The .NET TextBox isn't .NETified. It's just a .NET wrapper around the standard TextBox.
Trying to do anything with it is a PITA. Alot of the stuff you can do with many controls, although the properties/methods are there, they just don't work as expected. Can't give specifics to back this up because I've blocked my last experience of this out of my brain as it was painful!
Someone (MS?) really needs to make a proper .NET TextBox, I did start myself - but it was bloody hard work and I gave up!
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
Hi Devs,
I am trying to return a string which goes out of scope.
public static string test(Guid ID)
{
if (a == n )
{
string abc = x.group;
}
return abc
}
What would be the best way to return the abc string because as it is declared in bracket, it gets out of scope.
Thank You
|
|
|
|
|
Either by returning from inside the if statement like this:
public static string test(Guid ID)
{
if (a == n )
{
string abc = x.group;
return abc;
}
else
{
return String.Empty;
}
}
Or by creating the string and setting a default value first:
public static string test(Guid ID)
{
string abc = String.Empty;
if (a == n )
{
abc = x.group;
}
return abc;
}
Simon
|
|
|
|
|
|
Hi,
if that poses a problem, do yourself a favor: go to a bookstore, look at some tutorials on C#, buy one and study it.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
I don't agree with you here Lucy.
You learn more when you do stuff rather than reading it. So practical plus theory is a good way.
|
|
|
|
|
OK, have it your way. I won't waste any more of your time by offering readable advise, you just keep trying.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
AndyInUK wrote: You learn more when you do stuff rather than reading it.
So why use CodeProject? Do you not think you will have to read what people post in response to your questions.
Also, it is not always the case you learn stuff more by doing it. Your original post said you has trouble with using a value which was not declared in scope (scope being a word you must have learnt somewhere) - no matter how many times you right the same code, it wont suddenly start working. Therefore you have to research, usually by reading, why you have the problem and how to solve it.
In some cases you can use trial and error with a value to change a result, but as Luc hinted, it would be better to read a book on basics than to just 'do' stuff until it passes the compiler checks (which does not guarantee it will work how you want anyway)
Anyway, to make a contribution to your OP...
Based on the example you gave, I think a property would be best suited here...
public static string ABC{
get{return x.group;}
}
...this avoids the needless parameter and if statement in your function, however if you need a function like you have exemplified then I would do as follows...
public static string Test(Guid id)
{
if(a == n)
return x.group;
return string.Empty;
}
I hope you avoidance of reading has not had an impact on your ability to read my post...
Good luck for the future
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
I detected some sarcasm in your response. We can no longer do that. Perhaps the following would have been better:
It may be advantageous to obtain a tutorial or other material which will facilitate your education in C#.
|
|
|
|
|
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Hi Joe,
I don't know where the sarcasm would be in my message; and IMO if it were there, it would still be OK as the question was already answered satisfactorily. What would be unacceptable is sneering at an OP while no effective answers are given.
And I missed three essential parts of my message in yours:
1. going to a bookstore, as opposed to ordering at Amazon or downloading something
2. looking at several books, in order to pick the one one likes most (for whatever reason)
3. studying it (to learn a lot; just owning a book isn't sufficient).
So you haven't convinced me a bit to alter my ways. I remain open for new attempts though.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Actually, I'd be happy with just calling him a dumb ass.
modified on Tuesday, July 14, 2009 1:19 PM
|
|
|
|
|
and i would be happy to call you as dick head
|
|
|
|
|
That's Mr. Dick Head to you.
|
|
|
|
|
Luc Pattyn wrote: 1. going to a bookstore, as opposed to ordering at Amazon or downloading something
Exercise is the key to a healthy lifestyle.
Luc Pattyn wrote: 2. looking at several books, in order to pick the one one likes most (for whatever reason)
What about if your reason for buying a book is to own the first book you look at in the book store you go into? Would that come under "(for whatever reason)"
Luc Pattyn wrote: 3. studying it (to learn a lot; just owning a book isn't sufficient).
oh but there are many thing you could potentially learn by buying books without reading them. For instance, you could learn where the best place to buy books from is or how you need to buy a bigger shelf for all your new books to fit on
Of course, I'm only playing with you Luc, I'm sure I speak for many when I say you are a very valued member here at CP
Life goes very fast. Tomorrow, today is already yesterday.
|
|
|
|
|
Hi musefan,
1. I know I should exercise more (and program less).
2. the first book I see in a book store is the book they want to sell most, not something I pay attention to. I'll make up my own mind. The "for whatever reason" really shields me from people asking "which book should I buy?" which I cannot answer since that depends on prior knowledge and experience, taste of style, need for exact information/examples/exercises, etc.
3. I probably own more books than I have read books, so there is a reason I always write "buy and study a book". It may be comforting to keep a book handy, but it is you working through it that raises your knowledge.
musefan wrote: I'm sure I speak for many when I say ...
Well thanks.
I do like a pun and a joke, that should be obvious by now, however my first concern is helping people who seriously want to be helped. When they don't take my advise, I like to think it's their loss, not mine. And I avoid the obstinate easily, my memory is serving me very well. Bye bye Andy (and several others that will remain unnamed but not forgotten).
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
<br />
public static string test(Guid ID){ return(a == n )?x.group:null;} <br />
|
|
|
|
|
now i may have to develop a win apps which grab image from mobile camera whatever cam will capture and my apps will display those pic in my desktop apps in such a way as if user will think image is broadcasting directly from mobile camera to my desktop apps.i never work before with mobile apps so it will be great help if someone tell me the logic to finished this apps.
tbhattacharjee
|
|
|
|