|
Each messenger will be different; you may need to use proprietary protocols to interoperate with each. Maybe the GAIM[^] project will help you get started?
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Homosexuality in Christianity
Judah Himango
|
|
|
|
|
Hi all,
quick question. I've built a small project and I want to add a splash screen to my application. Does .net provide any splash screen components to make life easier or do I have to write from scratch?
Thanks in adavnce.
Rich
|
|
|
|
|
A splash screen is just a form without the title bar (Form->BorderStyle = FormBorderStyle::None), basically. Roll your own, or search CP for an existing.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: Homosexuality in Christianity
Judah Himango
|
|
|
|
|
Hello All,
I have a assignment something like this
LPTHREAD_START_ROUTINE a = ThreadProc;
Where ThreadProc is the thread function
After the above assignment a and ThreaProc shows different pointer value. Which is understandable.
My question is how do I get the ThreadProc pointer value back from a. How should my variable declaration look like
i.e if ThreadProc shows 0x00401028 in the watch window
and a shows 0x00401c90
then how do I obtain back 0x00401028 from a.
Rajdeep
|
|
|
|
|
Ok. So I'm working on a web service client in unmanaged C++ which is derived from CSoapSocketClientT.
I know that when creating a web service in .Net(C#,vb,c++) one have to use (through CookieContainer property) CookieContainer class to maintain session between requestes to the server. Is there something similar for unmananged C++ web service client? Or is generated (at "add web reference.." time) code's doing it somehow magicaly on it's own?
Please help!
|
|
|
|
|
How would I do this? Can some one direct me to a good tutorial. For what I'm trying to do now I really only need to use *.txt files, but it would be good to know how to use others as well.
|
|
|
|
|
|
Only Visual C++ .NET 2003 is affected by this problem so far.
Problem:
I currently have vc++ 6.0, vc++.net 2003 and vc++ 2005 beta2 (i also got beta1). I recently having some wied error with vc++ 2005 giving out error and error about each time I was moving the mouse. I decided to try to reinstall it to fix it (it didn't). An another problem popped up just after I reinstalled my vc++ 2005 with my vc++.net 2003. When I started it an open one of my project, I was having now that error that was keeping popping :
Compiling...
Form1.cpp
Compiling managed resources...
error: Entrée ResX non valide.
error: Specific exception: TargetInvocationException Message: Entrée ResX non valide. ---> TargetInvocationException: Une exception a été levée par la cible d'un appel. ---> InvalidOperationException: Impossible de charger ImageList.
2 error(s).
Test4 : error PRJ0002 : error result returned from 'resgen.exe'. My windows xp is in french, it's why a part of the error is in french.
It pretty ennuing when you need to build your project and that your project is using that feature. The problem is actually in cause by some wierd problem when the compiler parse your image data in the resx file. Some syncronisation problem happen. I tried many thing like reinstalling vc++.net 2003->test failed, reinstalling vc++2005->test failed again.
Solution:
Install VC++ 2005 Express Edition Beta 2. Create a similar project. Put in the form a imagelist and bring all your picture in. Save that project somewhere. Open the file Form1.resx (Form1 is name that your given to the form) with notepad. Browse down to the location where the imagelist is. It should look like that :
<metadata name="imageList1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
<data name="imageList1.ImageStream" mimetype="application/x-microsoft.net.object.binary.base64">
<value>
AAEAAAD LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAA8
BwAAAk1TRnQBSQFMAgEBDQEAAQ4BAAEEAQABEAEAARABAAT/AQUBAAj/AUIBTQF2BwABdgMAASgDAAFA
AwABQAMAAQEBAAEEBgABCBgAAYACAAGAAwACgAEAAYADAAGAAQABgAEAAoACAAPAAQADgAMAAf8CAAH/
AwAC/wEAAf8DAAH/AQAB/wEAAv8CAAP/QwABDwL/AfAcAAEPAf8BDwHwHAABDwH/AQAB8BoAAQgBiAEP
Af8cAAEIAf8BDwH/AQsBgBoAAQgB9wEPAf8BCwFwGgABCAH/AwABuBoAAQgB9wF3AfgBAAG3GgABCAL/
AfgBAAELAYAZAAEIA4gBAAELIAABEbkAAQgGiAGAGAABCAb/AYAOAALgAQ8E/wHwAgABCAb/AYAJAAGQ
AwACDgEAAQ8BAAHwAgAB8AIAAQgB+AKI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gEiAUAAYsDewIAAbsBswEwBwAEiAwAAQgDiAIAAQsBux8AAbA9AAFCAU0BPgcAAT4DAAEo
AwABQAMAAUADAAEBAQABAQYAAQIWAAP/AQAC/wYAAfABDwYAAfABDwYAAfABDwYAAfABDwYAAYABDwYA
AYABDwYAAYABDwYAAYABBwYAAYABhwYAAYABwwYAAYABwwYAAf8B4QYAAf8B4wYAAv8GAAL/BgAQ/wGA
AQED/wHxAQABDwGAAQEB+QHPAd8B4AEAAQ8BgAEBAfMB5wGMAUEBAAEPAYABAQHzAecBCAEjAQABDwGA
AQEB8wHnAQABdwEAAQ8BgAEBAfMB5wEYAa8BAAEJAYABAQHnAfMBrwHfAQABAQGAAQEB8wHnAfYBqwEA
AQEBgAEBAfMB5wH4AXEB+AEBAYABAQHzAecB/AEhAfwBAQGAAQEB8wHnAfwBIQH+AQkBgAEBAfkBzwH+
ASMH/wF3Ff8B9wT/AfMC/wHjBP8B8QH/AeABwQL/AYAB8QH4Av8BgAL/AYAB8QH4AX8BgQEAAf8BwQGA
AeMB/AE/Af8BAAHHAYgBgAHjAfgBHwHTAQABgAEcAYABxwH4AR8B/wEBAaABPgGAAccB/AE/Af8BgwHP
AZwBgAGPAfwBHwH/AccB/wGIAYABjwH+AQ8B/wHvAf8BwQGIAR8B/gEPBP8BiAEfGf8B7wf/AccH/wGD
AcABHwL/AYAC/wHBAcABDwHgAQ8BAAF/Af8BAwHAAQcBwAEHAQABfwH/AXcBwAEDAcABBwEAAX8B/wF/
AcABAQHAAQcBAAEDAf8BdwHAAQEBwAEHAQABAQHvAWMBwAEBAcABBwGAAQEBxwFBAeABAQHAAQcB/AEB
AYABAAHwAQEBwAEHAfwCAQHxAfgBAQHgAQ8B/AEBAYAB+wH8AQEC/wH+AQMBwQf/AeMH/wH3B/8L
</value>
</data>
Copy it and go in your project in which one you have problem with the imagelist and replace the current code. Go build your project and it should work.
This is only a temp solution and you should try to completly reinstall your operating system and your vc++.net 2003.
I hope that it will be usefull to someone.
|
|
|
|
|
Hi,
I'm using Visual C++ and is trying to generate different icons between release and debug executables. How should I do that?
Thanks,
vandz
|
|
|
|
|
you can use #if macro and check whether debug, then load the debug icon else release icon.
|
|
|
|
|
Thanks for the info. What should I put in my code for the #if macro to check whether it is debug?
Thanks.
|
|
|
|
|
#ifdef _DEBUG
make use of the above #if macro and assign some variable value for debug version and for release version.
Before starting the application. Check the variable value and determine whether it is debug or release version.
Work hard and bit of luck is KEY to SUCCESS.
|
|
|
|
|
Hey there!
I'm writing a DLL as a plugin for an unmanaged piece of software, the DLL exports a struct with basic information such as name etc. There is no problem with this, it works well, other than a couple of compiler warnings that I wont go into just yet.
In my plugin, I want to use a managed class (__gc). I declare it as global like this:
<code>gcroot<COmg __gc*> Omg;</code>
Here is the class definition:
<code>public __gc class COmg
{
public:
COmg( void ) {}
~COmg( void ) {}
};</code>
This still compiles and loads fine, until I try and use my gcroot'ed class:
<code>Omg = new COmg;</code>
It dies at this line, as far as I know im linking with the .NET framework fine, because everything compiles and runs, and i've done similar projects to this in the past. I tried calling this in try/catch braces but it doesn't help.
I'd appreciate any help! Thanks.
P.S. Here are the compiler warnings that may be contributing to this?
<code>MSVCRT.lib(checkclr.obj) : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators
MSVCRT.lib(secchk.obj) : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators
Core.obj : warning LNK4210: .CRT section exists; there may be unhandled static initializers or terminators</code>
|
|
|
|
|
I need my dialog boxes to have the behaviour that if it is open, you can't activate any other form until it is "closed" (usually by clicking 'OK', 'Cancel', or something similar); i.e., if I have opened an "Options" box from my main form, I can't click back in my main form until I either set all my options and click 'OK', or just click 'Cancel'... And if you do try to click back into the main form, it will make a beep...
For now, I just hide the main form, show the dialog, then when the user is done in the dialog, hide it and reshow the main form... Obviously, I don't really like doing it this way but can't figure out how to provide the functionality I described... Any help is greatly appreciated...
TIA
|
|
|
|
|
If you're using .NET, it's ShowDialog() instead of Show(), if it's MFC, it's DoModal() instead of whatever it is to show a modeless dialog box.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi everyone!
I’m trying to write a global hook in C# and C++\CLI. I’m almost done if there wasn’t this little delegate problem.
I get the function pointer to a delegate and pass it to my hook.dll. The delegate gets called for a few seconds but then the delegate seems to be relocated on the CLR heap.
If tried using a GCHandle but as far as I can tell this only prevents the garbage collector from collecting my delegate and doesn’t stop relocation.
Then there is pin_ptr. But a pinning pointer only works till it goes out of scope and it can only be declared locally so this happens immediately after I get the function pointer. By the way, I use ...
proc = (HOOKPROC)(Marshal::GetFunctionPointerForDelegate(innerEventHandler).ToPointer());
... to get the function pointer.
If anyone knows how to pin the delegate for as long as I need to point to it from unmanaged code or has any ideas, workarounds, etc. please let me know!
Thank you very much in advance!
Regards,
Florian
|
|
|
|
|
I don't know how your program runs. if your program is started by Application.Run, you should be able to pin the delegate BEFORE Application.Run and then cast it to a native global function pointer. if your program is started by MFC, you probably can not pin the delegate in CYourApp::Initinstance since, but you can pin it in your CWinApp::Run override and then cast it to a native global function pointer or a member varianble of CYourApp.
http://blog.joycode.com/jiangsheng
http://blog.csdn.net/jiangsheng
Command what is yours
Conquer what is not
---Kane
|
|
|
|
|
I wrote a little C# test app. Here's the relevant code snippet:
[STAThread]<br />
static void Main()<br />
{<br />
Form1 form = new Form1();<br />
TestDelegate test = new TestDelegate(form.Test);<br />
GCHandle handle = GCHandle.Alloc(test, GCHandleType.Pinned);<br />
Application.EnableVisualStyles();<br />
Application.Run(form);<br />
handle.Free();<br />
}
As soon as the debugger hits the line ...
GCHandle handle = GCHandle.Alloc(test, GCHandleType.Pinned);
... I get an ArgumentException:
Object contains non-primitive or non-blittable data.
In the MSDN it says:
An instance with nonprimitive (non-blittible) members cannot be pinned.
As I understand it, delegates can't be pinned by using GCHandle.Alloc().
|
|
|
|
|
delegate int BrowseCallBackProcDelegate(
unsigned/*HWND*/ hwnd, unsigned int/*UINT*/ uMsg
, unsigned/*LPARAM*/ lParam, unsigned/*LPARAM*/ lpData);
[STAThreadAttribute]
int main(array<system::string ^=""> ^args)
{
Form1^ pForm1=gcnew Form1();
// Enabling Windows XP visual effects before any controls are created
Application::EnableVisualStyles();
BrowseCallBackProcDelegate^ BCBD =
gcnew BrowseCallBackProcDelegate(Form1::BrowseForFileCallBackProc);
pin_ptr<browsecallbackprocdelegate^> pBCBD= &BCBD;
IntPtr delegatePointer =
Marshal::GetFunctionPointerForDelegate(BCBD);
pForm1->m_pbi->lpfn=static_cast<bffcallback>(delegatePointer.ToPointer());
// Create the main window and run it
Application::Run();
return 0;
}
http://blog.joycode.com/jiangsheng
http://blog.csdn.net/jiangsheng
Command what is yours
Conquer what is not
---Kane
|
|
|
|
|
Thank you for trying but my application is written in C#.
Only the hook Dll is written in C++/CLI because it's simply not possible to write a global hook entirely in managed code.
|
|
|
|
|
Thanks to Tomas Restrepo the problem is solved.
He wrote:
Florian,
> thank you for your reply but I'm afraid it doesn't work. The Dll project
> compiles fine but as soon as I run my C# test app I get an
> ArgumentException ("Object contains non-primitive or non-blittable
> data."). Seems like GCHandle::Alloc() has a problem with my delegate ...
> Any suggestions?
Ahh, true, you are completely correct.
Thinking more closely to what you want to do, I realize you might not need
to actually pin the delegate at all; just keep a reference to it alive so
that it is not garbage collected (it actually does *not* matter that it
moves around in memory, as that won't affect the call to it from unmanaged
code in this particular case).
I looked around to verify this, and found what I was looking for:
http://blogs.msdn.com/cbrumme/archive/2003/05/06/51385.aspx
Here, Chris Brumme explains in detail:
"Along the same lines, managed Delegates can be marshaled to unmanaged code,
where they are exposed as unmanaged function pointers. Calls on those
pointers will perform an unmanaged to managed transition; a change in
calling convention; entry into the correct AppDomain; and any necessary
argument marshaling. Clearly the unmanaged function pointer must refer to a
fixed address. It would be a disaster if the GC were relocating that! This
leads many applications to create a pinning handle for the delegate. This
is completely unnecessary. The unmanaged function pointer actually refers
to a native code stub that we dynamically generate to perform the transition
& marshaling. This stub exists in fixed memory outside of the GC heap.
However, the application is responsible for somehow extending the lifetime
of the delegate until no more calls will occur from unmanaged code. The
lifetime of the native code stub is directly related to the lifetime of the
delegate. Once the delegate is collected, subsequent calls via the
unmanaged function pointer will crash or otherwise corrupt the process. In
our recent release, we added a Customer Debug Probe which allows you to
cleanly detect this - all too common - bug in your code. If you haven't
started using Customer Debug Probes during development, please take a look!"
Hope this helps!
--
Tomas Restrepo
tomasr@mvps.org
http://www.winterdom.com/
My response:
Hi Tomas!
> Hope this helps!
Problem solved! :-) Thank you!
It had nothing to do with the delegate at all. The problem was the return
value in my unmanaged callback. The hook worked till the app window lost
focus. After reactivating the window my delegate didn't receive any
keystroke messages. I assumed that this was because the delegte has been
relocated on the heap. Actually at this point it should have been clear that
I'm wrong. My application didn't crash which most likely would have happend
if my function pointer was pointing "somewhere" in the memory.
I have a few more problems now but I think I can figure them out on my own.
Thanks again!
Regards,
Florian
|
|
|
|
|
How can i stop program from loading if another instance of that program exist.
|
|
|
|
|
|
Search this site - or pretty much any code site - for the word singleton.
Cheers,
Tom Archer - Visual C++ MVP
Archer Consulting Group
"So look up ahead at times to come, despair is not for us. We have a world and more to see, while this remains behind." - James N. Rowe
|
|
|
|
|
I am creating an aplication, that requires .NET Framework 1.1. I know how to check if framework is installed. I don't want to create a large instaler. My application only has about 120KB. I have use unmanaged command to detect if is installed. Then i have tried on another commputer with Windows 2000 without .NET Framework. And i got an error, that it wants to have mscorelib.dll. You can check a sample below to know what i think.
I hope you understand what i want to know.
#include "stdafx.h"
#include "Form1.h"
#include <windows.h>
using namespace CDDvdOrganizer;
bool IsDotNetInstalled()
{
HKEY key;
bool bRunInstall = true;
if (ERROR_SUCCESS == ::RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\.NETFramework\\policy\\v1.1", 0, KEY_READ, &key))
{
bRunInstall = false;
BYTE val[10];
DWORD len = 10;
if (ERROR_SUCCESS == ::RegQueryValueEx(key, "4322", NULL, NULL, &val[0], &len))
{
char *pVal = (char *)&val[0];
if (0 == ::strcmp(pVal, "3706-4322"))
{
bRunInstall = true;
}
::RegCloseKey(key);
}
if (bRunInstall == false)
{
::MessageBox(NULL, "You must instal .NET Framework 1.1", "Error", MB_OK | MB_ICONERROR);
}
}
return bRunInstall;
}
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
if (IsDotNetInstalled() == false)
{
PostQuitMessage(0);
}
System::Threading::Thread::CurrentThread->ApartmentState = System::Threading::ApartmentState::STA;
Application::Run(new Form1());
return 0;
}
ps: Sorry for my poor english.
|
|
|
|