|
Drat. I thought of using the 32770 class name, though I may have more than one dialog based app running. I want to FindWindow on a particular app.
Thanks anyway.
I feel like I'm diagonally parked in a parallel universe
Jeremy Davis
http://www.astad.org http://www.jvf.co.uk
|
|
|
|
|
If you have more instances running and you want to find out a window in a specific process then you should use EnumWindows and compare window title, class name and window thread. You can get window's thread with GetWindowThreadProcessId.
|
|
|
|
|
hi,
i want to make a very simpel programm that reads how much sound volume it messured by the microfone. Anyone knows how to do that?
[]D [] []D []
|
|
|
|
|
I am getting an assertion error at file WinCore.cpp at linenumber 312 while subclassing the frame window. This frame window is single document view widows which contain the Rich edit view and document. This Framewindow is in a exe module. I am trying to subclass this window with a class that is declared in a dll and derived from CWnd class.
The dll is a extension dll which is loaded at run time and there is one exportable function “AddplugIn” and class declaration derived form CWnd class.
Here is the code, where the dll is loaded at runtime using AfxLoadLibrary method and the call of the AddPlugIn method.
The address of the main frame window is passed to the dll. The code is as fallows
BOOL CNCStudioUIApp::InitInstance()
{
// Initialize OLE libraries
if (!AfxOleInit())
{
AfxMessageBox(IDP_OLE_INIT_FAILED);
return FALSE;
}
const char* plugin = "NCStudioPluginD.dll";
hPlugin = AfxLoadLibrary(plugin);
if(hPlugin == NULL)
{
MessageBox(“Failed to load the dll”);
Return FALSE;
}
AfxEnableControlContainer();
#ifdef _AFXDLL
Enable3dControls(); // Call this when using MFC in a shared DLL
#else
Enable3dControlsStatic(); // Call this when linking to MFC statically
#endif
// Change the registry key under which our settings are stored.
SetRegistryKey(_T("Local AppWizard-Generated Applications"));
LoadStdProfileSettings(); // Load standard INI file options (including MRU)
// Register the application's document templates. Document templates
// serve as the connection between documents, frame windows and views.
CSingleDocTemplate* pDocTemplate;
pDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CNCStudioUIDoc),
RUNTIME_CLASS(CMainFrame), // main SDI frame window RUNTIME_CLASS(CNCStudioUIView));
pDocTemplate->SetContainerInfo(IDR_CNTR_INPLACE);
AddDocTemplate(pDocTemplate);
// Parse command line for standard shell commands, DDE, file open
CCommandLineInfo cmdInfo;
ParseCommandLine(cmdInfo);
// Dispatch commands specified on the command line
if (!ProcessShellCommand(cmdInfo))
return FALSE;
CMenu* pMenu = m_pMainWnd->GetMenu();
NCStudio::CNCStudioDLL uiDll;
typedef BOOL (PLUGINPROC)(NCStudio::CNCStudioDLL&);
m_pMainWnd->ShowWindow(SW_SHOW);
uiDll.setMenu(pMenu);
uiDll.setFrameWnd(GetMainWnd());
PLUGINPROC* pFunction = (PLUGINPROC *)GetProcAddress(hPlugin, "AddPlugin");
if(pFunction != NULL)
{
BOOL bSuccess = (*pFunction)(uiDll); //AddPlugin method call
if(bSuccess)
{
m_pMainWnd->DrawMenuBar();
TRACE("Successfully added the plugin");
}
}
// The one and only window has been initialized, so show and update it.
m_pMainWnd->UpdateWindow();
return TRUE;
}
In the dll I am subclassing the frame window the code like this
extern "C"
{ PLUGIN_EXP_IMP BOOL AddPlugin(CNCStudioDLL& ui)
{
//subclassing window
CWnd* pMainWnd = ui.getFrameWnd();
if (!ncPlugIn.SubclassWindow(pMainWnd->GetSafeHwnd()))
// ncPlugIn is the object declared globally in the dll it is the object of a class derived from CWnd. Here I am getting the above assertion error
{
TRACE("Failed to subclass client window\n");
return -1; // fail to create
}
return true
}
Please, Can any body tell me why I am getting this assertion and what is the wrong in my code and tell me how I can avoid it.
|
|
|
|
|
I am not sure whats wrong with your code, but this article of mine Plug-in architecture[^] should support what you are trying to do.
Roger Allen
Sonork 100.10016
Were you different as a kid? Did you ever say "Ooohhh, shiny red" even once? - Paul Watson 11-February-2003
|
|
|
|
|
seems, that nobody can help me
i have 3 main problems, i just cant solve, although they sound easy:
1. I cant change the icon of the addin button.(i always have the default button, a smiley)
(sounds like a easy problem,he? TRY IT!!!,change it to a custom icon!)
2. I cant assign a shortcut, i tried the following but it didnt worked(it compiles, but it does not assign the key)
//in the onconnection method:
SAFEARRAY arrSafe;
arrSafe.fFeatures =FADF_BSTR;
arrSafe.cbElements =35; //maby not necessary
arrSafe.cDims = 1; //maby not necessary
BSTR bstrShortCut =A2BSTR("Global::alt-s");
arrSafe.pvData = bstrShortCut;
VARIANT var1;
var1.vt = VT_ARRAY;
var1.parray = &arrSafe;
pCreatedCommand->put_Bindings(var1);
3. I would like to install my addins(the buttons) by default in a menu next to "Tools" which is called "MyAddins". how can i do this??? (i can manually make a new menu (Tools->customize,etc..) and then install my addin in there automatically (IfFailGoCheck(pCommandBars->get_Item(CComVariant(L"MyAddins"), &pMenuBarCommandBar), pMenuBarCommandBar);
but i cant make this "MyAddins" Menue automatically by code!!
THE FIRST DUDE, WHICH CAN HELP ME IN ANY OF THE 3 ISSUES (ISSUE 2. IS THE EASYEST, I GUESS)
WILL BE NOMINATED FOR THE OFFICAL "ADDIN-MASTER OF THE YEAR AWARD"
|
|
|
|
|
I need to have more than one view in my application
so I have wrote the following function.
void CMyDoc::CreateAllViews()
{
CCreateContext l_Context;
l_Context.m_pCurrentDoc = this;
CView* l_pActiveView = g_pMainFrame->GetActiveView();
::SetWindowLong(l_pActiveView->m_hWnd, GWL_ID, 0);
l_Context.m_pNewViewClass = RUNTIME_CLASS(CRilevamentoDatiView);
m_pRilevamentoDatiView = (CRilevamentoDatiView*)STATIC_DOWNCAST(CView, g_pMainFrame->CreateView(&l_Context));
l_Context.m_pNewViewClass = RUNTIME_CLASS(CStatisticheView);
m_pStatisticheView = (CStatisticheView*)STATIC_DOWNCAST(CView, g_pMainFrame->CreateView(&l_Context));
l_Context.m_pNewViewClass = RUNTIME_CLASS(CFiltriView);
m_pFiltriView = (CFiltriView*)STATIC_DOWNCAST(CView, g_pMainFrame->CreateView(&l_Context));
l_Context.m_pNewViewClass = RUNTIME_CLASS(CConfigurazioneView);
m_pConfigurazioneView = (CConfigurazioneView*)STATIC_DOWNCAST(CView, g_pMainFrame->CreateView(&l_Context));
}
The problem is the following:
views creation is ok but all of them looks like the last one created
in my function.
Is it possible to have multiple views in a SDI project ??
Does someone knows why my function doesn't works ???
|
|
|
|
|
Just have a look on this website...
|
|
|
|
|
I need to have more than one view in my SDI project.
I'd prefer to don't create a new view and destroy the old one
any time I have to change view.
I'd prefer to create all my views at the creation of the application
and to manage them into an array (statically).
Is it possible to do that ???
I have wrote this function:
void CMyDoc::CreateAllViews()
{
CCreateContext l_Context;
l_Context.m_pCurrentDoc = this;
CView* l_pActiveView = g_pMainFrame->GetActiveView();
::SetWindowLong(l_pActiveView->m_hWnd, GWL_ID, 0);
l_Context.m_pNewViewClass = RUNTIME_CLASS(CRilevamentoDatiView);
m_pRilevamentoDatiView = (CRilevamentoDatiView*)STATIC_DOWNCAST(CView, g_pMainFrame->CreateView(&l_Context));
l_Context.m_pNewViewClass = RUNTIME_CLASS(CStatisticheView);
m_pStatisticheView = (CStatisticheView*)STATIC_DOWNCAST(CView, g_pMainFrame->CreateView(&l_Context));
l_Context.m_pNewViewClass = RUNTIME_CLASS(CFiltriView);
m_pFiltriView = (CFiltriView*)STATIC_DOWNCAST(CView, g_pMainFrame->CreateView(&l_Context));
l_Context.m_pNewViewClass = RUNTIME_CLASS(CConfigurazioneView);
m_pConfigurazioneView = (CConfigurazioneView*)STATIC_DOWNCAST(CView, g_pMainFrame->CreateView(&l_Context));
l_Context.m_pNewViewClass = RUNTIME_CLASS(CDatiAnamnesticiView);
m_pDatiAnamnesticiView = (CDatiAnamnesticiView*)STATIC_DOWNCAST(CView, g_pMainFrame->CreateView(&l_Context));
l_Context.m_pNewViewClass = RUNTIME_CLASS(CModInterazioneView);
m_pModInterazioneView = (CModInterazioneView*)STATIC_DOWNCAST(CView, g_pMainFrame->CreateView(&l_Context));
}
But It doesn't work... views creation ends with success but when I try
to show a view it looks like the last view created by my function...
All views created by my function, lokks like the last one created !!!
Does someone knows which is the problem ??? Or can supply me any other
information in order to have multiple views in my project ???
Thanks a lot
|
|
|
|
|
How To Detect Proxy Settings and Manipulate them for Internet connection ?.
I am using Sockets For communication between PC's
|
|
|
|
|
For IE, use InternetQueryOption and InternetSetOption , but be aware proxy settings don't have any effect on your sockets (maybe you're mixing proxies and gateways?)
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Sir, can you tell me why the following code not works in VC++ 7.0
std::hash_set<std::string> myhash;<br />
myhash.insert("string");
Strange that it works if we use std::set instead of std::hash_set
|
|
|
|
|
In which sense doesn't it work? Compiler error, crash at run-time? With some more info maybe I can be more helpful.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Dear Joaquín i require little help. The question is related to std::set
I am doing something like this:
std::hash_set<std::string> myset;<br />
std::string country="india";<br />
<br />
myset.insert(country);
But the code above is not working on my VC++ 7.0 compiler. I am getting an error. I am copying below:
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\xhash(38): error C2440: 'type cast' : cannot convert from 'const std::string' to 'size_t'
|
|
|
|
|
Are you sure you've inserted the appropriate #include <string> ? Other than that, I cannot figure out how such a simple piece of code is causing the compiler to go awry.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Sorry, actually the code above is working, but if i use std::hash_set instead of std::set , it does not work. I am writing code below:
using namespace std;
int main(int argc, char* argv[])
{
string name = "india";
hash_set<string> val;
val.insert(name);
return 0;
}
The error i am getting is:
c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\xhash(38): error C2440: 'type cast' : cannot convert from 'const std::string' to 'size_t'
Yes i am including all the required headers.
|
|
|
|
|
how to add entry to personnel address book programatically
|
|
|
|
|
Hello,
I'm using following function :
-----------------------------------------------------------------------
void DrawTransparentBitmap(HDC hdc, HBITMAP hBitmap, int xStart,
int yStart, COLORREF cTransparentColor)
{
BITMAP bm;
COLORREF cColor;
HBITMAP bmAndBack, bmAndObject, bmAndMem, bmSave;
HBITMAP bmBackOld, bmObjectOld, bmMemOld, bmSaveOld;
HDC hdcMem, hdcBack, hdcObject, hdcTemp, hdcSave;
POINT ptSize;
hdcTemp = CreateCompatibleDC(hdc);
SelectObject(hdcTemp, hBitmap); // Select the bitmap
GetObject(hBitmap, sizeof(BITMAP), (LPSTR)&bm);
ptSize.x = bm.bmWidth; // Get width of bitmap
ptSize.y = bm.bmHeight; // Get height of bitmap
DPtoLP(hdcTemp, &ptSize, 1); // Convert from device
// to logical points
// Create some DCs to hold temporary data.
hdcBack = CreateCompatibleDC(hdc);
hdcObject = CreateCompatibleDC(hdc);
hdcMem = CreateCompatibleDC(hdc);
hdcSave = CreateCompatibleDC(hdc);
// Create a bitmap for each DC. DCs are required for a number of
// GDI functions.
// Monochrome DC
bmAndBack = CreateBitmap(ptSize.x, ptSize.y, 1, 1, NULL);
// Monochrome DC
bmAndObject = CreateBitmap(ptSize.x, ptSize.y, 1, 1, NULL);
bmAndMem = CreateCompatibleBitmap(hdc, ptSize.x, ptSize.y);
bmSave = CreateCompatibleBitmap(hdc, ptSize.x, ptSize.y);
// Each DC must select a bitmap object to store pixel data.
bmBackOld = (HBITMAP)SelectObject(hdcBack, bmAndBack);
bmObjectOld = (HBITMAP)SelectObject(hdcObject, bmAndObject);
bmMemOld = (HBITMAP)SelectObject(hdcMem, bmAndMem);
bmSaveOld = (HBITMAP)SelectObject(hdcSave, bmSave);
// Set proper mapping mode.
SetMapMode(hdcTemp, GetMapMode(hdc));
// Save the bitmap sent here, because it will be overwritten.
BitBlt(hdcSave, 0, 0, ptSize.x, ptSize.y, hdcTemp, 0, 0, SRCCOPY);
// Set the background color of the source DC to the color.
// contained in the parts of the bitmap that should be transparent
cColor = SetBkColor(hdcTemp, cTransparentColor);
// Create the object mask for the bitmap by performing a BitBlt
// from the source bitmap to a monochrome bitmap.
BitBlt(hdcObject, 0, 0, ptSize.x, ptSize.y, hdcTemp, 0, 0,
SRCCOPY);
// Set the background color of the source DC back to the original
// color.
SetBkColor(hdcTemp, cColor);
// Create the inverse of the object mask.
BitBlt(hdcBack, 0, 0, ptSize.x, ptSize.y, hdcObject, 0, 0,
NOTSRCCOPY);
// Copy the background of the main DC to the destination.
BitBlt(hdcMem, 0, 0, ptSize.x, ptSize.y, hdc, xStart, yStart,
SRCCOPY);
// Mask out the places where the bitmap will be placed.
BitBlt(hdcMem, 0, 0, ptSize.x, ptSize.y, hdcObject, 0, 0, SRCAND);
// Mask out the transparent colored pixels on the bitmap.
BitBlt(hdcTemp, 0, 0, ptSize.x, ptSize.y, hdcBack, 0, 0, SRCAND);
// XOR the bitmap with the background on the destination DC.
BitBlt(hdcMem, 0, 0, ptSize.x, ptSize.y, hdcTemp, 0, 0, SRCPAINT);
// Copy the destination to the screen.
BitBlt(hdc, xStart, yStart, ptSize.x, ptSize.y, hdcMem, 0, 0,
SRCCOPY);
// Place the original bitmap back into the bitmap sent here.
BitBlt(hdcTemp, 0, 0, ptSize.x, ptSize.y, hdcSave, 0, 0, SRCCOPY);
// Delete the memory bitmaps.
DeleteObject(SelectObject(hdcBack, bmBackOld));
DeleteObject(SelectObject(hdcObject, bmObjectOld));
DeleteObject(SelectObject(hdcMem, bmMemOld));
DeleteObject(SelectObject(hdcSave, bmSaveOld));
// Delete the memory DCs.
DeleteDC(hdcMem);
DeleteDC(hdcBack);
DeleteDC(hdcObject);
DeleteDC(hdcSave);
DeleteDC(hdcTemp);
}
-----------------------------------------------------------------------
I use function a lot and it works perfect. Recently , by chance i finded out
there's a problem in win98 ( second edition ) when using 16 BIT COLOR.
Here's example of how i use this function :
DrawTransparentBitmap(
m_hMemDC ,
HBITMAP(pictBubble),
nBubblePosX,
nBubblePosY,
CLR_TRANSPARENT);
Here's my define of transparent color ( "clean" CYAN )
#define CLR_TRANSPARENT RGB(0,255,255)
As i said , it works everywhere except win98 ( second edition ) when using 16 BIT COLOR.
As far as i know , each loaded image produces it's own palette. In some cases , it can
cause color to be changed to nearest color and obviously , transparency won't work in this
case since above function needs transparent color to be exact down to pixel.
So , i tried to use following to work it out :
cTransparentColor = GetNearestColor( hdc , CLR_TRANSPARENT );
But , it didn't work.
Need your help ( it's pretty urgent ) , thanks !
P.S. I just prefer solution that won't force me to change everything , but a small patch
|
|
|
|
|
|
All right I'll give you this one function, since it is in my list for posseble aticles to this site. (it is only a part of of the file - the MSDN has an aticle on this suject some where, not to mention the wwww)
////////////////////////////////
// John R. Shaw (2001/03/23)
// Transparent Blit for Windows 3.x and above
//////////////////////////////////////////////////////////
BOOL TransBitBlt(
HDC hdcDest, // handle to destination DC
int nXOriginDest, // x-coord of destination upper-left corner
int nYOriginDest, // y-coord of destination upper-left corner
int nWidthDest, // width of destination rectangle
int hHeightDest, // height of destination rectangle
HDC hdcSrc, // handle to source DC
int nXOriginSrc, // x-coord of source upper-left corner
int nYOriginSrc, // y-coord of source upper-left corner
int nWidthSrc, // width of source rectangle
int nHeightSrc, // height of source rectangle
UINT crTransparent // color to make transparent
)
{
// Win 98 and above
if( g_TransBlt.DrawTransparent(
hdcDest, nXOriginDest, nYOriginDest, nWidthDest, hHeightDest,
hdcSrc , nXOriginSrc , nYOriginSrc , nWidthSrc , nHeightSrc, crTransparent) )
{
return TRUE;
}
// Win 3.x and above
// Note: This technique may not necessarily work on printer devices.
// Create temporary DCs
HDC hdcTemp = CreateCompatibleDC(hdcDest);
if( hdcTemp == NULL )
return FALSE;
HDC hdcMask = CreateCompatibleDC(hdcDest);
if( hdcTemp == NULL )
{
DeleteDC(hdcTemp);
return FALSE;
}
// Create temporary Bitmaps
HBITMAP hBmpMask = CreateBitmap(nWidthSrc,nHeightSrc,1,1,NULL);
if( hBmpMask == NULL )
{
DeleteDC(hdcMask);
DeleteDC(hdcTemp);
return FALSE;
}
HBITMAP hBmpTemp = CreateCompatibleBitmap(hdcDest,nWidthSrc,nHeightSrc);
if( hBmpTemp == NULL )
{
DeleteObject(hBmpTemp);
DeleteDC(hdcMask);
DeleteDC(hdcTemp);
return FALSE;
}
HGDIOBJ hOldBmpMask = SelectObject(hdcMask,HGDIOBJ(hBmpMask));
// Use temporary DC to reduce flicker
HGDIOBJ hOldBmpTemp = SelectObject(hdcTemp,HGDIOBJ(hBmpTemp));
if( BitBlt(hdcTemp,0, 0, nWidthSrc,nHeightSrc, hdcDest, nXOriginDest, nYOriginDest, SRCCOPY) )
{
// If we made it here there should be no more possible problems
// Create mask using crTransparent
COLORREF OldBkColor = SetBkColor(hdcSrc,crTransparent);
BitBlt(hdcMask,0, 0, nWidthSrc,nHeightSrc,hdcSrc, nXOriginSrc,nYOriginSrc, SRCCOPY);
SetBkColor(hdcTemp,OldBkColor);
// Draw bitmap using mask
BitBlt(hdcTemp,0, 0, nWidthSrc,nHeightSrc,hdcSrc, nXOriginSrc,nYOriginSrc, SRCINVERT);
BitBlt(hdcTemp,0, 0, nWidthSrc,nHeightSrc,hdcMask, 0, 0, SRCAND);
BitBlt(hdcTemp,0, 0, nWidthSrc,nHeightSrc,hdcSrc, nXOriginSrc,nYOriginSrc, SRCINVERT);
// Copy Temporary DC to Destination DC
BitBlt(hdcDest,nXOriginDest, nYOriginDest, nWidthDest,hHeightDest,hdcTemp, 0, 0, SRCCOPY);
}
// Clean up
SelectObject(hdcMask,hOldBmpMask);
SelectObject(hdcTemp,hOldBmpTemp);
DeleteDC(hdcMask);
DeleteDC(hdcTemp);
DeleteObject(hBmpMask);
DeleteObject(hBmpTemp);
return TRUE;
}
Trust in the code Luke. Yea right!
|
|
|
|
|
John,
Thanks , but your answer isn't answering my question. I do know how works
TransparentBlt function , i asked what's wrong in my function for drawing transparent BITMAPS.
|
|
|
|
|
|
IncrediBuild[^] is a development tool that substantially boosts C/C++ compilation speed, reducing a project's build time by up to 90%.
|
|
|
|
|
Hi Friends
I need to shutdown a PC By Code ?
I know ExitWindowsEx but can't understand all the Parameters
The Code Should be able to turn off the PC On All Windows OS.
|
|
|
|
|
BOOL ExitWindowsEx(<br />
UINT uFlags,
DWORD dwReserved
);
set uFlags to EWX_POWEROFF to turn off !!
|
|
|
|
|