|
make your function ActivateFrame look like this,
void CChildFrame::ActivateFrame(int nCmdShow) <br />
{<br />
CMDIChildWnd::ActivateFrame(nCmdShow);<br />
BOOL ret=SetWindowPos(&CMDIChildWnd::wndBottom, 0, 0, 0, 0,<br />
SWP_NOMOVE|SWP_NOSIZE|SWP_NOACTIVATE);<br />
<br />
}
|
|
|
|
|
Thanks for this. Unfortunately, it doesn't quite work. The window that is currently active loses focus to the new window and things don't draw properly if the child windows are maximized.
I tried saving the currently-active MDI child window (by calling MDIGetActive()) and then making it active again after creating the new background window but this is problematic for me since my app does some processing when child windows gain and lose focus.
The two most common elements in the universe are Hydrogen and stupidity. - Harlan Ellison
Awasu 2.1.2 [^]: A free RSS reader with support for Code Project.
|
|
|
|
|
Hi,
I grouped some buttons in the Group box and When I hiding the Groupbox, I want to hide all the controls in it without doing individual hide.
How can i do that...?
OR
Any other controls in MFC to act like this?
please help mee
thanks in advance
shijuck
|
|
|
|
|
as it is not VB, you cannot act directly on all the controls of a group box by setting its property to hide/show. you can however write a function which will do the job, and then, call the function once.
there is anyway one bad method which need you to set the controls IDs consecutive, and then making something like this :
<font color=blue>void</font> MyGroupBox::theFunction(<font color=blue>int</font> newState) {
<font color=green>
<font color=blue>int</font> iFirstId = <font color=purple>IDC_CONTROL_1</font>;
<font color=blue>int</font> iLastId = <font color=purple>IDC_CONTROL_N</font>;
<font color=blue>for</font> (<font color=blue>int</font> i = iFirstId; i < iLastId; i++) {
((CWnd*)GetDlgItem(i))->ShowWindow(newState);
}
}
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
You can use GetDlgItem() and then GetNextWindow() to iterate over all controls in a group (checking the WS_GROUP flag). You need however to be very diciplined when setting these flags in your dialog/form.
|
|
|
|
|
See here and here (I've used this one).
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
I have compiled my code in VC 7.1. It was written in VC 6.0.
Following is the compilation error I get:-
error C2872: 'IXMLDOMNodePtr' : ambiguous symbol
Has any one face a similar problem ? Any solution for it.
Best Regards,
|
|
|
|
|
try using namespace::IXMLDOMNodePtr instead...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
This error comes in file which is in the folder of the MS VS 2003. I cant modify it. How can I remove this ambuigity, any idea ???
Best Regards,
|
|
|
|
|
I used the function bellow:
HRESULT ConfigNet()
{
IWbemLocator *pLocator=NULL;
IWbemServices *pNamespace=NULL;
IWbemClassObject *pClass=NULL;
IWbemClassObject *pInputParamClass=NULL;
IWbemClassObject *pInputParamInstance=NULL;
IWbemClassObject * pOutInst = NULL;
BSTR InstancePath = SysAllocString(L"Win32_NetworkAdapterConfiguration=2");
HRESULT hr;
BSTR Path = SysAllocString(L"\\\\MyComputerName\\root\\cimv2");
BSTR ClassPath = SysAllocString(L"Win32_NetworkAdapterConfiguration");
BSTR MethodName = SysAllocString(L"EnableStatic");
LPCWSTR Arg1Name = L"IPAddress";
VARIANT var1;
LPCWSTR Arg2Name = L"SubnetMask";
VARIANT var2;
__try
{
CreateOneElementBstrArray(&var1, L"10.0.0.101");
CreateOneElementBstrArray(&var2, L"255.255.255.0");
CoCreateInstance(CLSID_WbemLocator, 0,
CLSCTX_INPROC_SERVER,
IID_IWbemLocator, (LPVOID*)&pLocator);
hr = pLocator->ConnectServer(Path,NULL, NULL, NULL, 0, NULL, NULL,
&pNamespace);
hr = CoSetProxyBlanket( pNamespace,
RPC_C_AUTHN_WINNT,
RPC_C_AUTHZ_NONE,
NULL,
RPC_C_AUTHN_LEVEL_CALL,
RPC_C_IMP_LEVEL_IMPERSONATE,
NULL,
EOAC_NONE);
if(!SUCCEEDED(hr))
{
PrintWMIError(hr);
return hr;
}
if(SUCCEEDED(hr))
{
hr = pNamespace->GetObject(ClassPath, 0, NULL, &pClass, NULL);
}
if(!SUCCEEDED(hr))
{
PrintWMIError(hr);
return hr;
}
if(SUCCEEDED(hr))
{
hr = pClass->GetMethod(MethodName, 0, &pInputParamClass, NULL);
}
if(!SUCCEEDED(hr))
{
PrintWMIError(hr);
return hr;
}
if(SUCCEEDED(hr))
{
hr = pInputParamClass->SpawnInstance(0, &pInputParamInstance);
}
if(!SUCCEEDED(hr))
{
PrintWMIError(hr);
return hr;
}
if(SUCCEEDED(hr))
{
hr = pInputParamInstance->Put(Arg1Name, 0, &var1, 0);
}
if(!SUCCEEDED(hr))
{
PrintWMIError(hr);
return hr;
}
if(SUCCEEDED(hr))
{
hr = pInputParamInstance->Put(Arg2Name, 0, &var2, 0);
}
if(!SUCCEEDED(hr))
{
PrintWMIError(hr);
return hr;
}
if(SUCCEEDED(hr))
{
hr = pNamespace->ExecMethod(InstancePath, MethodName, 0, NULL,
pInputParamInstance, &pOutInst, NULL);
}
if(!SUCCEEDED(hr))
{
PrintWMIError(hr);
return hr;
}
}
__finally
{
if(pInputParamInstance)
pInputParamInstance->Release();
if(pInputParamClass)
pInputParamClass->Release();
if(pClass)
pClass->Release();
if(pNamespace)
pNamespace->Release();
if(pLocator)
pLocator->Release();
}
return hr;
}
every function works well. but nothing changed.
Why??
BSTR Path = SysAllocString(L"\\\\MyComputerName\\root\\cimv2");
for a test,the above line must be modified.replace "MyComputerName" with your own computer name.
Thank you everyone.
|
|
|
|
|
I found i'd better post all the code here. a console application.;P
#define _WIN32_DCOM
#include <wbemidl.h>
#pragma comment(lib,"Wbemuuid.lib")
#include <atlbase.h>
//#include "wbemcli.h"
#include "objbase.h"
#include <windows.h>
#include <comutil.h>
#pragma comment(lib, "comsupp.lib")
void CreateOneElementBstrArray(VARIANT* v, LPCWSTR s)
{
SAFEARRAYBOUND bound[1];
SAFEARRAY* array;
bound[0].lLbound = 0;
bound[0].cElements = 1;
array = SafeArrayCreate(VT_BSTR, 1, bound);
long index = 0;
BSTR bstr = SysAllocString(s);
SafeArrayPutElement(array, &index, bstr);
SysFreeString(bstr);
VariantInit(v);
v->vt = VT_BSTR | VT_ARRAY;
v->parray = array;
}
HRESULT __fastcall UnicodeToAnsi(LPCOLESTR pszW, LPSTR* ppszA)
{
ULONG cbAnsi, cCharacters;
DWORD dwError;
// If input is null then just return the same.
if (pszW == NULL)
{
*ppszA = NULL;
return NOERROR;
}
cCharacters = wcslen(pszW)+1;
// Determine number of bytes to be allocated for ANSI string. An
// ANSI string can have at most 2 bytes per character (for Double
// Byte Character Strings.)
cbAnsi = cCharacters*2;
// Use of the OLE allocator is not required because the resultant
// ANSI string will never be passed to another COM component. You
// can use your own allocator.
*ppszA = (LPSTR) CoTaskMemAlloc(cbAnsi);
if (NULL == *ppszA)
return E_OUTOFMEMORY;
// Convert to ANSI.
if (0 == WideCharToMultiByte(CP_ACP, 0, pszW, cCharacters, *ppszA,
cbAnsi, NULL, NULL))
{
dwError = GetLastError();
CoTaskMemFree(*ppszA);
*ppszA = NULL;
return HRESULT_FROM_WIN32(dwError);
}
return NOERROR;
}
void PrintWMIError(HRESULT hr)
{
IWbemStatusCodeText * pStatus = NULL;
HRESULT hres = CoCreateInstance(CLSID_WbemStatusCodeText, 0,
CLSCTX_INPROC_SERVER,IID_IWbemStatusCodeText, (LPVOID *) &pStatus);
if(S_OK == hres)
{
BSTR bstrError;
hres = pStatus->GetErrorCodeText(hr, 0, 0, &bstrError);
if(S_OK != hres)
bstrError = SysAllocString(L"Get last error failed");
LPSTR pszStatusTextA;
UnicodeToAnsi(bstrError, &pszStatusTextA);
printf("%s\n",pszStatusTextA);
CoTaskMemFree(pszStatusTextA);
pStatus->Release();
SysFreeString(bstrError);
}
}
HRESULT ConfigNet()
{
IWbemLocator *pLocator=NULL;
IWbemServices *pNamespace=NULL;
IWbemClassObject *pClass=NULL;
IWbemClassObject *pInputParamClass=NULL;
IWbemClassObject *pInputParamInstance=NULL;
IWbemClassObject * pOutInst = NULL;
BSTR InstancePath = SysAllocString(L"Win32_NetworkAdapterConfiguration=2");
HRESULT hr;
BSTR Path = SysAllocString(L"\\\\MyComputerName\\root\\cimv2");
BSTR ClassPath = SysAllocString(L"Win32_NetworkAdapterConfiguration");
BSTR MethodName = SysAllocString(L"EnableStatic");
LPCWSTR Arg1Name = L"IPAddress";
VARIANT var1;
LPCWSTR Arg2Name = L"SubnetMask";
VARIANT var2;
__try
{
CreateOneElementBstrArray(&var1, L"10.0.0.101");
CreateOneElementBstrArray(&var2, L"255.255.255.0");
CoCreateInstance(CLSID_WbemLocator, 0,
CLSCTX_INPROC_SERVER,
IID_IWbemLocator, (LPVOID*)&pLocator);
hr = pLocator->ConnectServer(Path,NULL, NULL, NULL, 0, NULL, NULL,
&pNamespace);
hr = CoSetProxyBlanket( pNamespace,
RPC_C_AUTHN_WINNT,
RPC_C_AUTHZ_NONE,
NULL,
RPC_C_AUTHN_LEVEL_CALL,
RPC_C_IMP_LEVEL_IMPERSONATE,
NULL,
EOAC_NONE);
if(!SUCCEEDED(hr))
{
PrintWMIError(hr);
return hr;
}
if(SUCCEEDED(hr))
{
hr = pNamespace->GetObject(ClassPath, 0, NULL, &pClass, NULL);
}
if(!SUCCEEDED(hr))
{
PrintWMIError(hr);
return hr;
}
if(SUCCEEDED(hr))
{
hr = pClass->GetMethod(MethodName, 0, &pInputParamClass, NULL);
}
if(!SUCCEEDED(hr))
{
PrintWMIError(hr);
return hr;
}
if(SUCCEEDED(hr))
{
hr = pInputParamClass->SpawnInstance(0, &pInputParamInstance);
}
if(!SUCCEEDED(hr))
{
PrintWMIError(hr);
return hr;
}
if(SUCCEEDED(hr))
{
hr = pInputParamInstance->Put(Arg1Name, 0, &var1, 0);
}
if(!SUCCEEDED(hr))
{
PrintWMIError(hr);
return hr;
}
if(SUCCEEDED(hr))
{
hr = pInputParamInstance->Put(Arg2Name, 0, &var2, 0);
}
if(!SUCCEEDED(hr))
{
PrintWMIError(hr);
return hr;
}
if(SUCCEEDED(hr))
{
hr = pNamespace->ExecMethod(InstancePath, MethodName, 0, NULL,
pInputParamInstance, &pOutInst, NULL);
}
if(!SUCCEEDED(hr))
{
PrintWMIError(hr);
return hr;
}
}
__finally
{
if(pInputParamInstance)
pInputParamInstance->Release();
if(pInputParamClass)
pInputParamClass->Release();
if(pClass)
pClass->Release();
if(pNamespace)
pNamespace->Release();
if(pLocator)
pLocator->Release();
}
return hr;
}
int _tmain(int argc, _TCHAR* argv[])
{
CoInitialize(NULL);
ConfigNet();
CoUninitialize();
printf("Program end\n");
return 0;
}
|
|
|
|
|
hi all,
Is there an Api through which i can control the "volume control balance" which appears in the dialog box which appears when we double click the sound icon in the systray.
thanking and regards,
ashwath.
|
|
|
|
|
See here.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
Thank you very much for the help.
Is there a method to actually mute the volume by checking the "muteall" checkbox from program.
|
|
|
|
|
ashwath2005 wrote:
Is there a method to actually mute the volume by checking the "muteall" checkbox from program.
Sure, just use a MIXERCONTROL_CONTROLTYPE_MUTE control type.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
In the code below ,where should i use the "MIXERCONTROL_CONTROLTYPE_MUTE"
control type.Kindly let me know.
MMRESULT result;
HMIXER hMixer;
result = mixerOpen(&hMixer, MIXER_OBJECTF_MIXER, 0, 0, 0);
//obtain a handle to the mixer device.
//we need to get the speaker line of the mixer device
MIXERLINE ml = {0};
ml.cbStruct = sizeof(MIXERLINE);
ml.dwComponentType = MIXERLINE_COMPONENTTYPE_DST_SPEAKERS;
result = mixerGetLineInfo((HMIXEROBJ) hMixer,&ml, MIXER_GETLINEINFOF_COMPONENTTYPE);
//we need to get the volume control of the speaker line.
MIXERLINECONTROLS mlc = {0};
MIXERCONTROL mc = {0};
mlc.cbStruct = sizeof(MIXERLINECONTROLS);
mlc.dwLineID = ml.dwLineID;
mlc.dwControlType = MIXERCONTROL_CONTROLTYPE_VOLUME ;
mlc.cControls = 1;
mlc.pamxctrl = &mc;
mlc.cbmxctrl = sizeof(MIXERCONTROL);
result = mixerGetLineControls((HMIXEROBJ) hMixer,
&mlc, MIXER_GETLINECONTROLSF_ONEBYTYPE);
//MIXERCONTROL_CONTROLTYPE_VOLUME
//set the volume level
MIXERCONTROLDETAILS mcd = {0};
MIXERCONTROLDETAILS_UNSIGNED mcdu = {0};
mcdu.dwValue = iVal; // the volume is a number between 0 and 65535
mcd.cbStruct = sizeof(MIXERCONTROLDETAILS);
mcd.hwndOwner = 0;
mcd.dwControlID = mc.dwControlID;
mcd.paDetails = &mcdu;
mcd.cbDetails = sizeof(MIXERCONTROLDETAILS_UNSIGNED);
mcd.cChannels = 1;
result = mixerSetControlDetails((HMIXEROBJ) hMixer,
&mcd, MIXER_SETCONTROLDETAILSF_VALUE);
|
|
|
|
|
My article has been updated with this information. Check it out.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
hi,
i'm passing a vector of doubles by reference to a function, which assigns some values to the vector. if i compile this function into a dll and link the library i get a run time debug assertion failure:
code to make library:
#include <vector>
using namespace std;
extern "C" __declspec(dllexport)void MyDblFunc(vector<double> &Dbl)
{
for(int i=0; i<10; i++)
{
Dbl.push_back(1.1*i);
}
return;
}
code to use the library function:
#include <vector>
#include <iostream>
#include <fstream>
using namespace std;
extern "C" __declspec(dllexport) void MyDblFunc(vector<double> &Dbl);
void main()
{
vector<double> MyDbl;
MyDblFunc(MyDbl);
int N= (int)MyDbl.size();
cout<<N<<'\n';
for(int i=0; i<N; i++)
{
cout<<MyDbl[i]<<'\n';
}
return;
}
which writes the expected output and then produces Debug Assertion Failures: _CrtIsValidHeapPointer(pUserData) and _pFirstBlock==pHead.
However, if i put the function body code in the source after main (ie not using a dll) then i get no such error. Why does this happen? and what can i do about it? i want to put as many of my subroutines as possible into dlls as they are common to many programs, and also i want to use vectors so that i can dynamically allocate memory at run time. Is there a difference between passing a vector by reference or passing a pointer to the vector... i have been told that the reference can get reallocated when the vector resizes which could cause a problem in the calling routine... any advice at all would be great.
Thanks for your help
|
|
|
|
|
i also read that 'STL classes are not safe for DLL's interfaces'. why?
|
|
|
|
|
This is not STL-specific problem. It happens because you allocate memory with one instance of CRT and then try to release it from another one.
Try one of the following two things:
1) Compile both the dll and exe with Multi-threaded Debug DLL (/MDd) option (in debug mode) so that both exe and dll share the same instance of CRT.
2) If you know in advance the size of the vector, reserve the memory for it before calling the dll function. This way, the same instance of CRT will allocate and release the memory:
void main()
{
vector<double> MyDbl(10);
MyDblFunc(MyDbl);
|
|
|
|
|
How do you measure a string with word wrap? I want to pass a text to the program, a Rectangle which to contain it in a given Bitmap, a starting font size, and I need the program to decrease the fontSize until the text fits the Rectangle. After the fontSize has been computed, the text will be drawn to the Bitmap using DrawString(...). However, I can't get MeasureString to compute the text limits. This is the code I use :
{
mFont = new Font(mFontFamily, mFontSize, UnitPixel);
DebugAssert(mFont != NULL);
FLOAT fontSize = mFontSize;
StringFormat *stringFormat = StringFormat::GenericTypographic()->Clone();
stringFormat->SetFormatFlags(0);
graphics.SetTextRenderingHint(TextRenderingHintAntiAlias);
RectF *textRectangle = new RectF(0, 0, 0, 0);
int codePointFitted;
int lines;
graphics.MeasureString(mTextString, mTextString.length(), mFont, layoutRectangle, stringFormat, textRectangle, &codePointFitted, &lines);
while (((textRectangle->Width > mMaxTextWidth) || (textRectangle->Height > mMaxTextHeight)) && (!(fontSize < 0)))
{
fontSize = fontSize - 1.0f;
mFont = new Font(mFontFamily, fontSize, UnitPixel);
DebugAssert(mFont != NULL);
graphics.MeasureString(mTextString, mTextString.length(), mFont, layoutRectangle, stringFormat, textRectangle);
}
if (fontSize < 5.0f)
fontSize = 5.0f;
mFont = new Font(mFontFamily, fontSize, UnitPixel);
DebugAssert(mFont != NULL);
delete stringFormat;
}
If I don't use a StringFormat the returned limits are 0.0, if I use it, it computes the limits exactly as those of the layoutRectangle. fontSize starts at about 120, and the limits of the layoutRectangle are (Width 180; Height 160), and the Text is long enough not to enter those limits. "HELLO WORLD" is long enough. Any help is appreciated .
|
|
|
|
|
Hello
I'm drawing some text on a texture. Now I would like to only draw the outline of the text in a different color. I use the D3DXCreateFont function and m_pFont->DrawText to display the text. Unfortunately, I couldn't find a way to get the outline of my text...
I read that creating a D3DText mesh object is very resource consuming, so I didn't want to do that...
Anybody can give me a hint?
|
|
|
|
|
I develop an application which adds the icon to system tray.
System tray icon contains menu items like.,1.start 2.shutdown.
>It contains min and close buttons
(dialog based appli).
>I dont want to terminate the application .,when I press close('X') button .It has to be hide .
When I press Shutdown in menu item it has to be destroyed.
Plz Give code , which is added in OnSysCommand
praveen Chowdam Kumar
|
|
|
|
|
HOW MANY TIMES WILL YOU ASK THIS FOR ?
did you ever seen what i told you in you previous thread ? if it doesn't help, just tell me, because i won't guess !
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
what does the MapViewOfFile exactly do?
i have used the createFileMapping function for a text file.
I would want to know what the MapViewOfFile exactly does?does it copy the contents of the file to the object in the memory or just return the base address of the object in memory?
|
|
|
|
|