Quantcast
Channel: Visual C forum
Viewing all 15302 articles
Browse latest View live

about dynamic create buttons within the CListCtrl

$
0
0

I define the CListCtrl class myself, and add the cbutton objects as the sub-member.

jusk like this, .h file:

---------------------------------------------------------------------------------------

class CListCtrlMy : public CListCtrl

{

DECLARE_DYNAMIC(CListCtrlMy)

public:
CListCtrlMy();

CButton m_myButton[10];

}

in the .cpp file, I dymanic create two buttons:

m_myButton[0].Create(_T("button1"),WS_CHILD | WS_TABSTOP | WS_VISIBLE | BS_PUSHBUTTON,
CRect(20,100,100,130),this,IDC_BUTTON_TEMP1);

m_myButton[1].Create(_T("button2"),WS_CHILD | WS_TABSTOP | WS_VISIBLE | BS_PUSHBUTTON,
CRect(20,140,100,170),this,IDC_BUTTON_TEMP2);

----------------------------------------------------------------------------------------

I push the "button1" firstly, the "button1" looks highlight, and then I push the "button2",

but both buttons remains highlight,  it looks bad, how do I remove the highlight of "button1" ?

thank u.


Why lstrcpy not work

$
0
0

When I start this code I have only  "Helo Win32". Why lstrcpy not work

LPTSTR autor,heloText;

TCHAR csysdata[100],local [100];


int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
                                                LPSTR lpszCmdLine, int nCmdShow)
{
heloText= TEXT("Helo Win32");
autor = TEXT("Autor <Maksim>");

lstrcpy(heloText,autor);

        LPCTSTR lpszHelloText = heloText;
LPCTSTR lpszHelloWndTitle = MESSAGE_TITLE;

    MessageBox(NULL, lpszHelloText, lpszHelloWndTitle, MB_OK);

}

reboot pc, miss dll

$
0
0
Recently, I have encountered the following problem:
Some program files lost after rebooting my PC. I had lost the libintl-8.dll of postgresql, and also some of my own application programs' DLL file.
This problems happened in many OSs, such as Windows 2008, Windows 2012, Windows 10.
I wonder if someone has also encountered this problem and can give me some advice to solve it. Thanks a lot.

A call to CFrameWnd::SetActiveView() makes my app crash at close...

$
0
0

I build a MFC application with Doc/View architecture and VS2015.

To make accelerator keys arrive to the good view, I concluded that I must call CFrameWnd::SetActiveView(...) and it works fine.

But in this case, my application crash when closing.

Investigating, I found that the exception occures in CFrameWnd::OnClose() and, reading the code, I think there is a problem.

Schematically, the CFrameWnd::OnClose() code is (I show only interesting lines of code) :

    CDocument* pDocument = GetActiveDocument();
...

pApp->CloseAllDocuments(FALSE);

...

    if (pDocument != NULL && pDocument->m_bAutoDelete)
    {
        BOOL bOtherFrame = FALSE;
        POSITION pos = pDocument->GetFirstViewPosition();
...

If a call to CFrameWnd::SetActiveView() is made, GetActiveDocument() return a non null pointer to a document.

But this document is deleted in CloseAllDocuments() and pDocument is pointing on a desallocated memory area.
The last piece of code generate an access violation.

What am I doing wrong?
What is the good practice with SetActiveView()?
Is there a bug in CFrameWnd::OnClose()?

Thanks in advance

Ludovic


WTSEnumerateProcesses failed with error code 1072

$
0
0

Hi All,

I have a Windows Service application (Dialog based), and from this application (from OnInitDialog) I am trying to create the instance of user based exe file (example: creating instance of myTestUser.exe for each user session) for each user session. This is done by using "WTSEnumerateProcesses" API call. In Windows XP (32bit) WTSEnumerateProcesses API call failed with error code 1072. Kindly see the below sample code:

bool CreateInstanceAtServiceStart()
{
PWTS_PROCESS_INFO pProcessInfo;
DWORD ProcessCount = 0;
CString strProcName = "";
bool bRet = false,
    bExplorer = false;
/////////////////////////
try
{
if(WTSEnumerateProcesses(WTS_CURRENT_SERVER_HANDLE, 0, 1, &pProcessInfo, &ProcessCount))

for(DWORD CurrentProcess = 0; CurrentProcess < ProcessCount; CurrentProcess++)
{
if(pProcessInfo[CurrentProcess].ProcessId != 0)
{
strProcName = CString(pProcessInfo[CurrentProcess].pProcessName);
if(strProcName.CompareNoCase("explorer.exe") == 0) 
{
// creating the instance based on the process ID
}
}
}//for
}
}
catch(...)
{
strProcName.Empty(); 
ZeroMemory(&pProcessInfo,sizeof(pProcessInfo));
return bRet;
}
strProcName.Empty(); 
ZeroMemory(&pProcessInfo,sizeof(pProcessInfo));
return bRet;
}

Kindly help me to solve this issue.

Thanks,

R-VR



Why I have error

$
0
0

TCHAR tchelloText[500];

int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
                                                LPSTR lpszCmdLine, int nCmdShow)
{

tchelloText = TEXT("Hello Win32");

}

Why I have error

expression must be a modifiable lvalue 

Function exceeds stack size

$
0
0

How do I go about resolving a warning like this?

warning C6262: Function uses '37648' bytes of stack:  exceeds /analyze:stacksize '16384'.  Consider moving some data to heap.

My method:

void CChristianLifeMinistryEditorDlg::OnBnClickedButtonOclmEditStudentAssignments()
{
	if (m_pEntry != NULL)
	{
		CChristianLifeMinistryStudentsDlg dlgStudents(this);

		if (IsModified())
			UpdateMeetingForDate(); // Get things in the right state

		RebuildStudentHistory();

		dlgStudents.SetStudentAssignHistoryPtr(&m_arySPtrStudentHist);
		dlgStudents.SetAssignedStudyPointsMapPtr(&m_mapStudentAssignedStudyPoints);
		dlgStudents.SetEntry(m_pEntry); // The student dialog will update the pointer
		if (dlgStudents.DoModal() == IDOK)
		{
			SetModified(true);
		}
	}
}

Capture from webcam?

$
0
0
how to capture video from webcam using C++, C in WINAPI Without using any third party  Library  ? 

Interop problem between DLL C++ MFC and CLI [TypeLoadException and more]

$
0
0
Hi all,

After 3 days of researches in the depths of Google and all dev forums, I'am asking for your help.

I'm doing dev / c ++ linux for more than 10 years, but today I have a new job and they ask me to develop on Windows environment with Visual Studio. I'm in the middle of the authorized period of self-training and despite hundreds of websites on about this subject I  am really not comfortable with the notions of managed object, COM, and finally... all the .NET environment ^^ So I am totally lost and no colleague to help me.

Today I have to write a DLL that contains a class with its pretty methods, and which creates a custom dialog box in which programs must send text messages. 

I specify: programs that use this DLL are written in C ++ MFC, C #, C ++ / CLI, delphi and Python ... 

So after several liters of sweat I wrote it in C ++ MFC, to have a dialog and a simple use with the outside. That I thought...

I managed to use C#, using the IUnknown interface and a small method to create an instance of my class.

In C ++ MFC I use it easily.

Where I'm blocked for 3 whole days this is for the C ++ / CLI. And that's where I need you!

Clearly I can call a basic method, but I can not create my graphic object and not call the constructor of my mfc class.


DLL header :

#ifdef CPPDLL_EXPORTS
#define CPPDLL_API __declspec(dllexport)
#else
#define CPPDLL_API __declspec(dllimport)
#endif


#include <Windows.h>

// Generate from Visual Studio, Menu "Tools/Create GUID"
// {0D825F4E-7028-4628-8EBA-BBF77610EC7E}
static const GUID IID_IMyInterface =
{ 0xd825f4e, 0x7028, 0x4628,{ 0x8e, 0xba, 0xbb, 0xf7, 0x76, 0x10, 0xec, 0x7e } };
struct IMyInterface : public IUnknown // COM Interface. Enables clients to get pointers to other interfaces on a given object through the QueryInterface method.
{
	STDMETHOD_(double, GetValue)() = 0;
	STDMETHOD(CustomMsgBox)(const char*) = 0;
};

// This class is exported from the MyClass.dll
class CPPDLL_API CMyClass: public IMyInterface
{
	volatile long refcount_;
public:
	CMyClass() : refcount_(1) {};

	STDMETHODIMP QueryInterface(REFIID guid, void **pObj)
	{
		if (NULL == pObj) {
			return E_POINTER;
		}
		else if (guid == IID_IUnknown) {
			*pObj = this;
			AddRef();
			return S_OK;
		}
		else if (guid == IID_IMyInterface) {
			*pObj = this;
			AddRef();
			return S_OK;
		}
		else {
			// Always set 'out' parameter
			*pObj = NULL;
			return E_NOINTERFACE;
		}
	}

	STDMETHODIMP_(ULONG) AddRef() {
		return InterlockedIncrement(&refcount_);
	}

	STDMETHODIMP_(ULONG) Release() {
		ULONG result = InterlockedIncrement(&refcount_);
		if (result == 0) delete this;
		return result;
	}

	STDMETHODIMP_(DOUBLE) GetValue() {
		return 3.14;
	}

	STDMETHODIMP ThrowError() {
		return E_FAIL;
	}

	CMyClass(int p_flagDebug, CWnd* p_Parent);
	CMyClass(int p_flagDebug, int left, int top, int right, int bottom);
	~CMyClass();
	// TODO: add your methods here.
	void WriteMessage(CString p_sMsg);
	void WriteMessage(const wchar_t* p_sMsg);
	void InitDlg();
	STDMETHODIMP CustomMsgBox(const char* p_sStr = nullptr);

private:
	void AppendText(HWND hEditWnd, LPCTSTR Text);
	void DoIt(const char *p_sStr, long p_lNumber);
	void *m_gui; // Handle on the child dialog.
	CWnd *m_parent; // Handle on parent used to get the window position
	int m_Flag;
};


extern "C" CPPDLL_API LPUNKNOWN WINAPI CreateInstance(int FlagDebug, void* cwnd);

extern CPPDLL_API int nMyClass;

CPPDLL_API int fnMyClass(void);


DLL Code :

// MyClass.cpp : Defines the exported functions for the DLL application.
// @TODO : Manage close event of our Gui !!! (Actually nothing is done)

#include "stdafx.h"
#include "MyClass.h"
#include "Gui.h"
#include <Dbghelp.h>
#include <windowsx.h>

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


#pragma comment(lib, "dbghelp.lib")

// The one and only application object
CWinApp theApp;

HMODULE hModule; // Handle on this module
WNDPROC PrevPresLVWndProc; // Pointer to parent callback function
struct s_dialog {
	CGui* g_gui;
	CWnd* g_parent;
	int g_parentTop;
	int g_parentLeft;
	int g_parentRight;
	int g_parentBottom;
};
s_dialog g_dlg;

void SetGuiPosition(void);
LRESULT CALLBACK ParentCallback_OnMove(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);


/// <summary>
/// Constructor
/// </summary>
/// <param name="p_Parent">Parent CWND</param>
CMyClass::CMyClass(int p_flag, CWnd* p_Parent)
{
	if (NULL == p_Parent->m_hWnd)
	{
		AfxMessageBox(_T("CMyClass object creation may be before main dialog initialization"), MB_OK | MB_ICONERROR);
		return;
	}

	m_Flag = p_flag;

	if (m_Flag == 1)
	{
		// Initilization of the global struct g_dlg
		g_dlg.g_parent = m_parent = p_Parent;
		g_dlg.g_gui = NULL;
		m_gui = NULL;

		// Here we save pointer of the parent process
		PrevPresLVWndProc = (WNDPROC)GetWindowLongPtr(m_parent->m_hWnd, GWL_WNDPROC);
		// Now we associate the new callback method for event
		SetWindowLongPtr(m_parent->m_hWnd, GWL_WNDPROC, (LONG_PTR)&ParentCallback_OnMove);

		// Creation of our gui dialog
		CGui* mGuiLoc = new CGui;
		AFX_MANAGE_STATE(AfxGetStaticModuleState());
		m_gui = (void*)(new CGui());
		BOOL ret = ((CGui*)m_gui)->Create(MAKEINTRESOURCE(IDD_DIALOG1));
		((CGui*)m_gui)->ShowWindow(SW_SHOW);
		// Setting the dialog text
		((CGui*)m_gui)->m_EditBox.SetWindowText(_T("Text to display\r\n"));
		g_dlg.g_gui = ((CGui*)m_gui);
		InitDlg();
	}
}
CMyClass::CMyClass(int p_flag, int left, int top, int right, int bottom)
{
	m_Flag = p_flag;
	// Empty for the moment
}

/// <summary>
/// Destructor
/// </summary>
CMyClass::~CMyClass()
{
	SetWindowLongPtr(m_parent->m_hWnd, GWL_WNDPROC, (LONG_PTR)&PrevPresLVWndProc);
}

/// <summary>
/// Non member function - It is the new callback used to catch parent event
/// </summary>
/// <param name="all">that's default param used for this kind of callback method and content depends of message type (uMsg)</param>
LRESULT CALLBACK ParentCallback_OnMove(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	if (uMsg == WM_MOVE)
	{
		CRect rectGui;
		g_dlg.g_gui->GetWindowRect(&rectGui);
		CString s;
		s.Format(_T("gui top"));
		OutputDebugString((LPCTSTR)s);
	}
	return CallWindowProc(PrevPresLVWndProc, hwnd, uMsg, wParam, lParam);
}

LPUNKNOWN WINAPI CreateInstance(int p_flag, void* cwnd) {
	return new CMyClass(p_flag, CWnd::FromHandle((HWND)cwnd));
}


/// <summary>
/// Initialize Gui
/// </summary>
void CMyClass::InitDlg()
{
	if (m_Flag == 0) return;

	if (NULL == m_gui)
	{
		//SetGuiPosition();
	}
	else
	{
		if (((CGui*)m_gui)->IsWindowVisible() != TRUE)
		{
			((CGui*)m_gui)->ShowWindow(SW_SHOW);
		}
	}
}

/// <summary>
/// Add a message to Edit Box
/// </summary>
/// <param name="p_sMsg">The message to print</param>
void CMyClass::WriteMessage(CString p_sMsg)
{
	if (m_Flag == 0) return;

	InitDlg();
	if (NULL != m_gui)
	{
		AppendText(((CGui*)m_gui)->m_EditBox, p_sMsg);
	}
}

/// <summary>
/// Add a message to Edit Box - Compatibility for others languages
/// </summary>
/// <param name="p_sMsg">The message to print</param>
void CMyClass::WriteMessage(const wchar_t* p_sMsg)
{
	if (m_Flag == 0) return;

	CString csMsg(p_sMsg);
	WriteMessage(csMsg);
}

/// <summary>
/// Append a message to Edit Box
/// </summary>
/// <param name="p_hEditWnd">Handle on Edit Box</param>
/// <param name="p_text">The message to print</param>
void CMyClass::AppendText(HWND p_hEditWnd, LPCTSTR p_text)
{
	if (m_Flag == 0) return;

	int idx = GetWindowTextLength(p_hEditWnd);
	SendMessage(p_hEditWnd, EM_SETSEL, (WPARAM)idx, (LPARAM)idx);
	SendMessage(p_hEditWnd, EM_REPLACESEL, 0, (LPARAM)p_text);
}

/// <summary>
/// Display one message
/// <param name="p_sStr">Name</param>
/// </summary>
HRESULT CMyClass::CustomMsgBox(const char* p_sStr)
{
	if (m_Flag == 0) return S_OK; // Useless

	InitDlg();

	size_t outSize;
	wchar_t *wsStr = new wchar_t[256];
	// Conversion char* to wchar_t*
	mbstowcs_s(&outSize, wsStr, strlen(p_sStr) + 1, p_sStr, strlen(p_sStr));

	CString sTime(CTime::GetCurrentTime().Format("%H:%M:%S"));
	CString sMessage;
	sMessage.Format(_T("%s;%s;-\r\n"), sTime, wsStr);
	WriteMessage(sMessage);
	return S_OK;
}


void CMyClass::DoIt(const char *p_sStr, long p_lNumber)
{
	size_t outSize;
	wchar_t *wsStr = new wchar_t[256];
	// Conversion char* to wchar_t*
	mbstowcs_s(&outSize, wsStr, strlen(p_sStr) + 1, p_sStr, strlen(p_sStr));

	CString sTime(CTime::GetCurrentTime().Format("%H:%M:%S"));
	CString sMessage;
	sMessage.Format(_T("%s;%s;%d\n"), sTime, wsStr, p_lAllParamSum);

	WriteMessage(sMessage);
}

 

C# code used to call MFC DLL class methods :

using System;
using System.Text;
using System.Runtime.InteropServices;
using System.Windows.Forms;

/***
USAGE :
1 : Create a pointer on this object and initialize it ONLY after main dialog init !
2 : Create ONLY ONE object
Example to create object :
    CMyClass myCClassInstance = new CMyClass();
    IMyInterface myObjectInterface = myCClassInstance.LocCreateInstance();
    Console.WriteLine(myObjectInterface.GetValue());
***/


namespace MyNamespace
{
    [ComImport]
    [Guid("0D825F4E-7028-4628-8EBA-BBF77610EC7E")]
    [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
    public interface IMyInterface
    {
        [PreserveSig]
        double GetValue();
        IntPtr CustomMsgBox([MarshalAs(UnmanagedType.LPStr, SizeParamIndex = 3)] string str);
        void ThrowError();
    }
    ////////////////////////////////////////////////////////////
    // Inclusion of other needed stuff
    ////////////////////////////////////////////////////////////

    public class CMyClass
    {
        [DllImport("MyClass.dll")]
        extern static IMyInterface CreateInstance(int Flag, IntPtr o2);

        public IMyInterface LocCreateInstance(IntPtr o1)
        {
            return CreateInstance(1, o1);
        }
    }
}

 

This is the C++/CLI code I'm trying to do, I have and beautiful exception System.TypeLoadException : 

header :

using namespace System;
using namespace System::Text;
using namespace System::Runtime::InteropServices;
using namespace System::Windows::Forms;

namespace company
{
	namespace project
	{
		namespace module
		{
			public interface class IMyInterface
			{
				double GetValue();
			};

			public ref class CMyClass : IMyInterface //ref class CMyClass
			{
				public:
				CMyClass() {};

				[DllImport("MyClass.dll", EntryPoint = "_CreateInstance@8Z", CallingConvention = CallingConvention::StdCall)]
				IMyInterface^ CreateInstance(int Flag, IntPtr cwnd);

				[DllImport("MyClass.dll", EntryPoint = "?GetValue@CMyClass@@UAGNXZ", CallingConvention = CallingConvention::StdCall)]
				virtual double GetValue();
			};
		}
	}
}

Code :

	CMyClass^ m_cMyClass = gcnew CMyClass();
	IMyInterface ^m_i_MyInterface = m_cMyClass->CreateInstance(1, this->Handle);

Bellow the exception I catch :

	-		e	{"Méthode implémentée PInvoke virtuelle.":"company.project.module.CMyClass"}	System::Exception^ {System::TypeLoadException^}
		AssemblyName	"PCExample, Version=1.0.6198.29074, Culture=neutral, PublicKeyToken=null"	System::String^
		ClassName	"company.project.module.CMyClass"	System::String^+		Data	{System::Collections::ListDictionaryInternal^}	System::Collections::IDictionary^ {System::Collections::ListDictionaryInternal^}
		HResult	-2146233054	int
		HelpLink	nullptr	System::String^+		IPForWatsonBuckets	{28553626}	System::UIntPtr+		InnerException	nullptr	System::Exception^
		IsTransient	false	bool
		Message	"Méthode implémentée PInvoke virtuelle."	System::String^
		MessageArg	nullptr	System::String^
		RemoteStackTrace	nullptr	System::String^
		ResourceId	8209	int
		Source	"PCExample"	System::String^
		StackTrace	"   à PCExample.FormMain..ctor()\r\n   à main(String[] args) dans d:\\proje\\PCExample\\checkit\\c++_clr\\PCExample\\PCExample.cpp:ligne 19"	System::String^+		TargetSite	{Void .ctor()}	System::Reflection::MethodBase^ {System::Reflection::RuntimeConstructorInfo^}
		TypeName	"company.project.module.CMyClass"	System::String^
		WatsonBuckets	nullptr	System::Object^
		_HResult	-2146233054	int
		_className	nullptr	System::String^+		_data	{System::Collections::ListDictionaryInternal^}	System::Collections::IDictionary^ {System::Collections::ListDictionaryInternal^}
		_dynamicMethods	nullptr	System::Object^+		_exceptionMethod	{Void .ctor()}	System::Reflection::MethodBase^ {System::Reflection::RuntimeConstructorInfo^}
		_exceptionMethodString	nullptr	System::String^
		_helpURL	nullptr	System::String^+		_innerException	nullptr	System::Exception^+		_ipForWatsonBuckets	{28553626}	System::UIntPtr
		_message	"Méthode implémentée PInvoke virtuelle."	System::String^
		_remoteStackIndex	0	int
		_remoteStackTraceString	nullptr	System::String^+		_safeSerializationManager	{System::Runtime::Serialization::SafeSerializationManager^}	System::Runtime::Serialization::SafeSerializationManager^
		_source	"PCExample"	System::String^+		_stackTrace	array<char>(48)	System::Object^ {array<char>^}
		_stackTraceString	nullptr	System::String^
		_watsonBuckets	nullptr	System::Object^
		_xcode	-532462766	int+		_xptrs	{0}	System::IntPtr+		[Static Members]	

It is really important for me to understand and succed...

I hope you will understand my problem and help me. And I apologize about my english !

For information : I use the same target platform and same toolset. DLL is working really fine with C# and C++/MFC.

Thanks by advance,

nb

 

 

 

 

 



create 3 tabbed group document of equal size

$
0
0

Hi,

I would like to create some MDI tabbed group documents and I would like equal size for each one.

unfortunately creating a tabbed group divide actve gorup in 2 equal gorups, so if I create 3 groups by code I've got one of them occupying 50% of size and 2 others ones 25% each

is there a solution to equilibrate size for all groups.

thanks

Yan

How can I export from a DLL (via __declspec(dllexport)) a CWnd derived class?

$
0
0

Hi,

I have a CWnd derived GUI class called CGridCell, that is declared DECLARED_DYNCREATE(CGridCell) and I need to export this in a DLL because I need to code the following in the EXE that links with the DLL:

 
getGrid().SetCellType(row, Columns::Enabled, RUNTIME_CLASS(CGridCell));

I get a linker error like this:

error LNK2019: unresolved external symbol "public: static struct CRuntimeClass * __cdecl CGridCell::GetThisClass(void)"

Any ideas?

Juan Dent


Juan Dent

Very strange linking issue

$
0
0

Hello.  My basic situation is this:

  • Visual Studio 2015 Version 14.0.25123.00 Update 2.
  • I have five projects in one solution.
  • Three are static .lib projects, and two are exes.
  • Both executables link all three static .libs.
  • One executable links successfully, and one does not.
  • The one that does not compile says it cannot find a .lib and errors.
  • If I remove that .lib requirement, the next ones cannot be found either.  It is finding none of them.
  • I have repeatedly confirmed that the paths and settings for the non-linking executable project are correct and identical to the settings for the project which links successfully.
  • I have tried recreating the project for the non-linking executable from scratch and have the same problem.
  • In the non-linking executable's project, whenever I add a project reference, it is listed under References with a yellow triangle and an exclamation mark.
  • If I view the properties for one of these broken references, the 'Full Path' contains the following string: "The "Microsoft.VisualStudio.ProjectSystem.References.UnresolvedBuildDependencyProjectReference" reference could not be resolved."
  • The Assembly Name property is empty in those same properties.
  • If I view the properties for the same reference in the linking project, the Assembly Name property is correct, as is the path to the .lib file in 'Full Path'.
  • I have tried manually executing link.exe, and even that does not work.  It says that the .lib file(s) cannot be found.

I can provide any other information that might be necessary.  Please help me!

CAN SOMEONE PLEASE HELP ME :)

$
0
0
Hi there i was trying to make a program called the "loading system" it's like a prepaid loading machine etc. now what i want to do is when the user type their number it will identify what network(phone carrier) are they using for example they type: 09234234342 and then press enter then after that the program will say you are on this network "carrier".  How will i do that will i use if statements or something please help thank you :)

How to handle Keyboard keystroke event using Windows RawInput API's in c++ win32?

$
0
0

Hi Everyone,

Is there any console application for keystroke event handling using Windows RawInput API's in C++ Win32

I have tried different samples using these API, but could not solve it...

Can anyone please help on this...Thanks for the help...


Regards, Ravi Raj Nukala

DLL Problem

$
0
0

My first attempt to enable a dynamic DLL in an MFC application.  Here is the DLL code header file:

// USERDLL.h : main header file for the USERDLL DLL
//
#include "stdafx.h"

#pragma once

#ifndef __AFXWIN_H__
    #error "include 'stdafx.h' before including this file for PCH"
#endif

#include "resource.h"        // main symbols

// CUSERDLLApp
// See USERDLL.cpp for the implementation of this class
//

class CUSERDLLApp : public CWinApp
{
public:
    CUSERDLLApp();

// Overrides
public:
    virtual BOOL InitInstance();

    DECLARE_MESSAGE_MAP()
    void UserProgram(void);
};

And here is the cpp code:

// USERDLL.cpp : Defines the initialization routines for the DLL.
//

#include "stdafx.h"
#include "USERDLL.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


// CUSERDLLApp

BEGIN_MESSAGE_MAP(CUSERDLLApp, CWinApp)
END_MESSAGE_MAP()


// CUSERDLLApp construction

CUSERDLLApp::CUSERDLLApp()
{
    // TODO: add construction code here,
    // Place all significant initialization in InitInstance
}


// The one and only CUSERDLLApp object

CUSERDLLApp theApp;


// CUSERDLLApp initialization

BOOL CUSERDLLApp::InitInstance()
{
    CWinApp::InitInstance();

    AfxMessageBox(_T("INTO DLL"));

    return TRUE;
}


//extern "C" __declspec(dllexport) void CUSERDLLApp::UserProgram(void)
extern "C" void CUSERDLLApp::UserProgram(void)
{
    AFX_MANAGE_STATE(AfxGetStaticModuleState());
    AfxMessageBox(_T("INTO UserProgram"));
    return;
}

The main application has this at the top:

extern __declspec(dllimport) void UserProgram( void );
typedef void (*DLLPROC) ( LPTSTR );
HINSTANCE hinstDLL;
BOOL fFreeDLL;

And this when it starts up:

    if ( dsMultiMe == 0 ) {
        hinstDLL = LoadLibrary( "USERDLL.dll" );
        if ( hinstDLL != NULL ) {
            DLLPROC UserProgram;
            UserProgram = (DLLPROC) GetProcAddress( hinstDLL, "UserProgram");
            if ( UserProgram != NULL ) {
                UserProgram( 0 );

                fFreeDLL = FreeLibrary( hinstDLL );
            }
        }
    }

The DLL gets loaded and shows the box INTODLL.  But the UserProgram always comes back NULL.  Why?


where do I get the mfc140u.dll file?

$
0
0
where do I get the mfc140u.dll file?

CreateEvent is atomic function or not?

$
0
0

In official MSDN documentation nothing is said either CreateEvent function is atomic or not.

There is only note:

"If the named event object existed before the function call, the function returns a handle to the existing object and GetLastError returns ERROR_ALREADY_EXISTS"

But nothing is said about the atomic.

Does anybody know, CreateEvent is atomic function?

Can I use the same name for multiple named pipes?

$
0
0

Hi,

I have a program that creates multiple threads.  Each thread creates a process and communicates with the process through a named pipe.  My question is whether I can use the same name for these named pipes.  If I do use the same name, will the communication in a pair of a thread and its companion process interferes with another pair?  In other words, when a named pipe is created, is it public to everyone, or is it private between the parent and the child processes?

Thanks for any feedback.

JD

WNetCancelConnection2 does not close a connection

$
0
0
Hi there,


I'm using WNetCancelConnection2 to disconnect a unit from network.
The connection is previusly stablished with WNetAddConnection2 but WNetCancelConnection2 does not disconnect it.

Any idea?

DXGI_FORMAT_R16_UNORM vs DXGI_FORMAT_D16_UNORM

$
0
0
what is the difference in  DXGI_FORMAT_R16_UNORM and DXGI_FORMAT_D16_UNORM can one can be used instead of other?
Viewing all 15302 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>