|
Usually you get this exception when the signature of method you imported is incorrect. Have you looked at the source code of my articles to see how to declare FindWindow method? You can also find P/Invoke definitions here: P/Invoke[^] or you can use an addin for Visual Studio that generates signature - Redgate has one.
|
|
|
|
|
Ah thanks,
Yeah i was declaring it wrong, I had a look in your source code and imported the dll and function same as you. Now it works and returns the IntPrt.
Back to research for next step.
|
|
|
|
|
Nice to see that you are advancing. Please post if you need more help. Also, please report your progress when you are done Thanks.
|
|
|
|
|
Thank you for your interest it is extremely appriciated.
From what i can tell the next step is to get a count of the icons.
To do this i know i must send a message to the window with SendMessage().
I tried something along the lines of:
IntPtr intPrtShellTrayWnd = FindWindow("ToolbarWindow32", "");
int Count = (int)SendMessage(intPrtShellTrayWnd, TB_GETBUTTON, intPrtShellTrayWnd, "");
But i have no definition of TB_GETBUTTON. Im hoping to get it to result just a count of the icons, then ill worry about looping though the tray icons themselves.
Have you any idea on TB_GETBUTTON?
|
|
|
|
|
According to the article link you provided you need to send TB_BUTTONCOUNT message. Why don't you follow the article? Secondly, TB_BUTTONCOUNT and TB_GETBUTTON are integeres defined in some header value. So you need to find out int value of these constants and then either define the constants in your program or just use the integer values.
|
|
|
|
|
Thanks for the advice.
I read up a bit more, Also found this article:
http://www.codeproject.com/KB/shell/taskbarsorter.aspx[^]
Which supplies a good user32.cs for a win32api.
In the user32 class i have the TB_BUTTONCOUNT and GETBUTTON.
There is also a good TBBUTTON Struct for storing the hWnd info for each tray icon.
But that Article only works for the windows in the tray, not the notify icons.
To the point, I have gotten the count to work, and i can return the value of how many Nofication Icons there are,
But i am unsure of how for loop the send message to return each notify icons details.
In the C++ it is:
for(int i=0; i<count;>{
::SendMessage(m_hTrayWnd, TB_GETBUTTON, i, (LPARAM)data.GetData());
data.ReadData(&tb);
data.ReadData<traydata>(&tray,(LPCVOID)tb.dwData);
</traydata>
I have the TB_GETBUTTON but i am unsure of what to set for the data variable.
Could anyone offer some advice?
|
|
|
|
|
As I can see from the code author uses a class written by him so you need to import that class in your program using DllImport. I am not sure how to do that so you can ask the author of the article.
By the way, I have just remembered that there is another way (and probably easier) to call native methods from your application. Are you familiar with Managed c++? It's sort of combination of native c++ and managed code. You can write a dll in managed c++ that does the same job as the article and you will not need to use DllImport. You will just include the header files you need. The dll will be managed so you can reference it from your c# application. Here is an example:
Wrapping Around a Native C++ Class[^]
Netting C++[^]
Wrapping Unmanaged Classes Using Managed Extensions for C++[^]
NativeWrapper: a tool for Native Interoperability[^]
|
|
|
|
|
Thanks ill see if i can get in contact with him.
Have had no luck myself.
Also i dont have experience with managed c++.
|
|
|
|
|
In some code I'm working on, I encountered a line that reads something like this:
MyObject obj = new global::MyNamespace.MyObject();
What does the global:: part mean, and when should you use it?
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
It starts the qualification from the global namespace
MSDN[^]
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Expect everything to be hard and then enjoy the things that come easy. (code-frog)
|
|
|
|
|
I have searched over the net so much days, but no succes to find an article, topic or example that solve my problem. I would like to inject my Direct3D DLL to a 32 bit target D3D application in C# to take screenshots under Vista x64 (WOW64). I have no solution, no idea. Please wrtie or mail me a link where I can learn this very diffcult (for me) technique. I have working program under x86, but no succes on x64. Thank You!
|
|
|
|
|
|
Hi Guys
k here is what's happening.I am supposed to check in the STUDENT table if a student exists and then check if a module exists in the MODULE table.If they exist in both tables I am supposed to add the student(studentNumber) and the module(ModuleCode) to the STUDENTMODULE table(register them for the module).this is to avoid registering students that do not exist in the database.
How do i do this? plz help
|
|
|
|
|
You may want to ask this in this[^] forum instead.
|
|
|
|
|
|
I have an application that needs to create SQL statements based on user selection criteria. Therefore, the specific items in the SQL query must be variables. Unfortunately, I'm seeing a problem with a variable that has a quotation mark in it, such as Mark's Fish Market. When the application puts Mark's Fish Market into a query structured something like the following SQL snippet, the application generates an error. What's the best way to encode this variable as a string literal?
AND Owner = '" + strOwner + "'
Thanks.
|
|
|
|
|
polishprogrammer wrote: I have an application that needs to create SQL statements based on user selection criteria. Therefore, the specific items in the SQL query must be variables. Unfortunately, I'm seeing a problem with a variable that has a quotation mark in it, such as Mark's Fish Market. When the application puts Mark's Fish Market into a query structured something like the following SQL snippet, the application generates an error. What's the best way to encode this variable as a string literal?
AND Owner = '" + strOwner + "'
Well, I wouldn't do that for a start. You've just opened yourself to a whole host of problems because of the potential of SQL Injection Attacks. Use parameterised queries instead - you can create dynamic queries with parameterised queries you know, so have a go at that instead.
|
|
|
|
|
OK. So, if I set this up as a parameterized query, will that automatically eliminate the problem with single quotation marks?
|
|
|
|
|
|
Then that's what I'll do. Thanks.
|
|
|
|
|
|
Yes, it will.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
You should really not use string concatenation in your SQL statements. This opens up to serious injection attacks. Do go the parameterized query route.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
Hi,
I would like to create a proxy that communicates between C# and a Non-COM programming language (its DXL if interested).
What I want is to be able to get a c# application to call DXL methods and for a DXL script to call c# classes and methods. I know there is a way of doing it, and I know it is quite complicated and involved but for the life of me I can't remember the method.
Therefore, I was wondering if anyone on here would have any ideas.
Ta
Jon
ps DXl cannot interact with COM and is *NOT* an object orientated language.
|
|
|
|
|
So, I've essentially implemented a folder browser with a TreeView, and what I'm doing is trying to get it to remove flickering. Here's how it works:
Initially, say my folder structure starts like this, and the node that I want to refresh (folder nodes labeled with dots except for root) is indicated:
Root
|
|__. (node to be refreshed)
| |
| |__.
| |
| |__.
|
|__.
When I try to do the refresh, it ends up like this after I delete all the subnodes:
Root
|
|__. (in the process of being refreshed)
|
|__.
Then, it ends up like the initial diagram again. The problem is, I'm getting screen flickering everytime I do this operation. I've tried using TreeView.BeginUpdate() before calling the refresh, then TreeView.EndUpdate() after the refresh is done. Even when no folders have changed at all (i.e. the treeview ends up looking exactly the same in my Winforms application), I get the flicker. My assumption was that if the image on-screen didn't change, then nothing would have to be redrawn (thereby avoiding flicker). If not, then what assumptions can I make, and would there be any tips on solving this problem? Also, note that TreeView.DoubleBuffered doesn't actually do anything for this control.
|
|
|
|