dcsimg
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Language: C
Expertise: Advanced
Jul 29, 2008

WEBINAR:

On-Demand

Building the Right Environment to Support AI, Machine Learning and Deep Learning


Calling C Libraries from .NET

Suppose your library is in C and and your code is in .NET or VC++ (for a UI-based application). Further, suppose you want to display a message box whenever the library raises any error. In that situation, the following code is useful:

#include <stdio.h>
HWND g_AdtDlgWnd = NULL;
void UserWarning(char* arg1,char* arg2, ...)
{
	va_list list;
	char Buffer[1024];
	int ret;

	va_start(list,arg2);
	ret=vsprintf(Buffer,arg2,list);
	va_end(list);
	{
		HWND hwnd_cur=GetFocus();
		if(hwnd_cur == NULL)
		{
		hwnd_cur = GetADTDialogWindow();//Find handle of dlg
		}
		MessageBox(hwnd_cur,Buffer,arg1,MB_OK);
	}
}

HWND GetADTDialogWindow(void)
{
	if(g_AdtDlgWnd == NULL)
	return FindWindow(NULL,ADT_TITLE);//Provide title 
// of window (Dialog)
	else
		return g_AdtDlgWnd;
}
Now, call the function:

UserWarning("Data Transfer","Data not saved on server side");
Saroj Kabra
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date