|
Thanks Iain, but my question is about finding at run time *which
key* to set, rather than which function to use to set it.
The hard part is, since it seems to be a per user option, you
have to find out where msie keeps this option for the current user.
Have no fear of perfection - You will never reach it
|
|
|
|
|
Looking back at your question, I still think my answer was valid. But maybe that's my ego talking.
Anyway, I would lay *really* big odds that HKEY_USERS\...(numbers ommited)...\etc is the key that
is aliased by HKEY_CURRENT_USER\etc. Try changing a value in one, and see if that change is
reflected in the other.
HKCU is set when a user logs on, so it is safe on other machine, logins etc.
If you are unsure about specific keys, just get the RegMon[^] program from www.sysinternals.com[^].
A little bad news though. It is possible that the setting you are after is read when the explorer
control is created, rather than when used, which would ruin your plan. But its worth a go!
Iain.
|
|
|
|
|
Thanks again Iain,
I should've thought about using a utility like regmon myself, but...oh well.
It seems that the key that's changed is
HKLM\Software\Microsoft\Internet Explorer\AdvancedOptions\PRINT\BACKGROUND\CheckedValue
I think you're probably also right about having to change this value on control creation rather than on page display.
I'll do some tests and let you know how it works out.
Have no fear of perfection - You will never reach it
|
|
|
|
|
This is it:
In my dialog's OnInitDialog() :
HKEY hkeyIE;
if(RegOpenKeyEx(HKEY_CURRENT_USER,
"SOFTWARE\\Microsoft\\Internet Explorer\\Main",
0, KEY_ALL_ACCESS, &hkeyIE) == ERROR_SUCCESS)
{
ULONG nValSize = sizeof(m_strPrevIEPrintBGVal);
LPDWORD lpType = NULL;
if(RegQueryValueEx(hkeyIE, "Print_Background", 0, lpType, (BYTE*)(LPCSTR)m_strPrevIEPrintBGVal, &nValSize) == ERROR_SUCCESS)
TRACE("Registry key exists, prev value = %s\n", m_strPrevIEPrintBGVal);
TCHAR *strVal = _T("yes");
if(RegSetValueEx(hkeyIE, "Print_Background", 0, REG_SZ, (BYTE*)strVal, sizeof(strVal)) == ERROR_SUCCESS)
TRACE("Registry key found and written successfully.\n");
else
TRACE("Registry key found but writing failed.\n");
}
else
TRACE("Registry key not found!\n");
and in OnCancel() or OnOk() :
HKEY hkeyIE;
if(RegOpenKeyEx(HKEY_CURRENT_USER,
"SOFTWARE\\Microsoft\\Internet Explorer\\Main",
0, KEY_ALL_ACCESS, &hkeyIE) == ERROR_SUCCESS)
{
if(RegSetValueEx(hkeyIE, "Print_Background", 0, REG_SZ, (BYTE*)(LPCSTR)m_strPrevIEPrintBGVal, sizeof(m_strPrevIEPrintBGVal)) == ERROR_SUCCESS)
TRACE("Registry key changed to previous value = %s.\n", m_strPrevIEPrintBGVal);
}
Works like charm...
Have no fear of perfection - You will never reach it
|
|
|
|
|
Those numbers according to user names are listed -among others- under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\hivelist, but I would recommend not to bother extracting it from there since you can extract the same from where you need it.
Therefore
1.enumerate all keys of HKEY_USERS with RegEnumKeyEx
2.Construct regkeys (HKEY_USERS + ...number... + rest of key) with the data found in 1./
3.Try opening the keys with RegOpenKeyEx
4.If successful, change their value as you need.
Peter Molnar
|
|
|
|
|
Thanks Peter,
I'm not sure I have to change the per user setting after all (look at my reply to Iain above), but your info may come in quite handy anyway.
Have no fear of perfection - You will never reach it
|
|
|
|
|
I want to create tree in my Dlg.cpp dynamicly, i.e. I did create only Dialog window IDD_DIALOG without tree on it. Then I want to place tree on this window.
I had read MSDN Help & wrote in function OnInitDialog():
CWnd* pPar;
pPar->GetParent();
WINDOWPLACEMENT rc;
pPar->GetWindowPlacement(&rc);
rc.rcNormalPosition.bottom-=10;
rc.rcNormalPosition.left-=10;
rc.rcNormalPosition.right-=10;
rc.rcNormalPosition.top-=10;
pTreectrl->Create(WS_VISIBLE, rc.rcNormalPosition, pPar, 0x1005);
but it does not work - error. What I did incorrect?
Thanks in advance,
bilas.
|
|
|
|
|
WS_CHILD
--
Talk to the hand!
|
|
|
|
|
Remember to initialize the WINDOWPLACEMENT::length member with sizeof(WINDOWPLACEMENT) before calling GetWindowPlacement . Otherwise the function call will fail, and you will not receive the coordinates for rcNormalPosition .
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Did I understand correctly?
CWnd* pPar;
pPar->GetParent();
WINDOWPLACEMENT rc;
//I've added the next string but problem is alive
rc.length = sizeof(WINDOWPLACEMENT);
pPar->GetWindowPlacement(&rc);
rc.rcNormalPosition.bottom-=10;
rc.rcNormalPosition.left-=10;
rc.rcNormalPosition.right-=10;
rc.rcNormalPosition.top-=10;
pTreectrl->Create(WS_VISIBLE, rc.rcNormalPosition, pPar, 0x1005);
I'm beginner, so execuse me if my question is too stupid. But, can you wrote it correctly?
Thanks beforehand, bilas.
|
|
|
|
|
bilas wrote:
pTreectrl->Create(WS_VISIBLE, rc.rcNormalPosition, pPar, 0x1005);
Yes, but you can bitwise OR these styles together to get a combination of properties. e.g.:
m_TreeCtrl.Create(WS_CHILD | WS_VISIBLE | |TVS_HASLINES | TVS_HASBUTTONS, dwStyle, CRect(0,0,1,1), this, IDC_TREE);
I Dream of Absolute Zero
|
|
|
|
|
Ok, I'll post a small code fragment to help you out. Here, we assume that the name of your dialog class is CMyDialog , and that the .cpp file you mentioned contains the implementation of the class.
BOOL OnInitDialog (void)
{
RECT rectParentCA;
this->GetClientRect(&rectParent);<DIV>
rectParentCA.top += 10;
rectParentCA.left += 10;
rectParentCA.right -= 10;
rectParentCA.bottom -= 10;<DIV>
pTreeCtrl->Create( WS_VISIBLE | WS_CHILD | WS_BORDER, rectParentCA, this, 0x1005);
} This will create a tree control, making it a child of the dialog window.
Remember, that although the tree control object/window is automatically destroyed by the framework, the object reserved with new is not. You MUST call delete at the destructor of your dialog.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Thanks a lot. It really works! Thank you, men.
|
|
|
|
|
Hello Guys
I need some help regarding VC++, during the Application runtime..how can the get the Application Path ..i.e the Folder path from where the App runs
Thanks in Advance
Hariharan.S.N
|
|
|
|
|
Get the application object with AfxGetApp . The CWinApp::m_pszExeName member contains the path and name of the executable without the .EXE extension.
After getting this string, just manipulate it to remove the application's name (Remove characters until last character before NULL is '\').
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Antti Keskinen wrote:
After getting this string, just manipulate it to remove the application's name (Remove characters until last character before NULL is '\').
Or use _splitpath() .
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
One solution is GetModuleFileName().
Kuphryn
|
|
|
|
|
|
Did anyone experience any problems using CListCtrl::SortItems?
I take this code from MSDN for the sorting callback function but it does not work.
static int CALLBACK <br />
MyCompareProc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)<br />
{<br />
CListCtrl* pListCtrl = (CListCtrl*) lParamSort;<br />
CString strItem1 = pListCtrl->GetItemText(lParam1, 0);<br />
CString strItem2 = pListCtrl->GetItemText(lParam2, 0);<br />
<br />
return strcmp(strItem2, strItem1);<br />
}
The result of this code when I apply to my list is that MyCompareProc is called exactly as many times as the item number but this is clearly not sufficient for a complet alphabetical order!!! Thus the order is wrong.
Please help me!!!
Regards,
Andrea
|
|
|
|
|
De Nardis Andrea wrote:
...MyCompareProc is called exactly as many times as the item number but this is clearly not sufficient for a complet alphabetical order
That depends on the sorting algorithm used. While some algorithms look at each item multiple times (e.g., bubble), others look at each item fewer times, or even just once. I suspect that the algorithm employed by SortItems() is based on Hoare's partition-exchange (i.e., quicksort) algorithm.
As you add items to the control, a call to SetItemData() should be made. For example, the item's data could be a pointer to a CMyObject class. Then the comparison routine will look like:
static int CALLBACK
MyCompareProc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
{
CMyObject *p1 = (CMyObject *) lParam1;
CMyObject *p2 = (CMyObject *) lParam2;
CString str1 = p1->SomeString;
CString str2 = p2->SomeString;
return strcmp(str1, str2);
}
Five birds are sitting on a fence.
Three of them decide to fly off.
How many are left?
|
|
|
|
|
I want to show a popup menu when the right botton is pushed.
I write:
hMenu=LoadMenu(hInstance,MAKEINTRESOURCE(IDR_MENU_DESPLEGABLE));
SetMenu(hWindow,hMenu);
where IDR_MENU_DESPLEGABLE is the menu I want to show.
but this code puts my menu in the place of my window's menu. I would that this menu will be showed where the user pushes the right button, like the most Windows applications.
What code can I use?
sorry my english.
thanks
Christian
|
|
|
|
|
If "botton" means "button" then check this code:
CWnd *pBtn = GetDlgItem (IDC_BTNMNU);<br />
CRect btnrect, wndrect;<br />
<br />
pBtn->GetWindowRect (&btnrect);<br />
GetWindowRect (&wndrect);<br />
CPoint mnupoint (btnrect.left, btnrect.bottom);<br />
BOOL bRet = menu.CreatePopupMenu ();<br />
bRet = menu.TrackPopupMenu (TPM_LEFTALIGN | TPM_LEFTBUTTON, <br />
mnupoint.x, <br />
mnupoint.y, <br />
this);<br />
<br />
<br />
when IDC_BTNMNU is the name of the button.
regards,
Andrea
|
|
|
|
|
Try TrackPopupMenu() function SDK or MFC
for example
void CMyView::OnRButtonDown(UINT nFlags, CPoint point)
{
CMenu menu;
if (menu.LoadMenu(IDR_MYMENU))
{
CMenu* pPopup = menu.GetSubMenu(0);
ASSERT(pPopup != NULL);
pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON,
point.x, point.y, this);
}
}
and better than OnRButtonDown() OnContextMenu()
viliam
|
|
|
|
|
I have followed your words with my simple C version:
Menu=LoadMenu(hInstance,MAKEINTRESOURCE(IDR_MENU_DESPLEGABLE));
TrackPopupMenuEx(hMenu,TPM_LEFTBUTTON|TPM_LEFTALIGN|TPM_TOPALIGN,LOWORD(lParam),HIWORD(lParam),hWindow,NULL);
but I still have a small problem:
-The popup menu isn't showed complet, only is showed the border but it works fine when calls the WM_COMMAND.
Why the popup menu isn't showed normal??
thanks
Christian
|
|
|
|
|
PLEASE HELP: I'm trying to populate the fields in the 'wave properties dialog'. What I'm I doing wrong?
typedef struct output_tag // any special vars associated with output file
{
short nFile;
long lSize;
DWORD dwDataOffset;
long lSamprate;
WORD wBitsPerSample;
WORD wChannels;
DWORD dwFormat;
BOOL bWroteHeader;
char szTITLE[256]; // Title Displayed
char szARTIST[256]; // Artist
char szNAME[256]; // Name
char szGENRE[256]; // Genre
char szKEYWORDS[256]; // Keywords
char szSOURCE_FORM[256]; // Source Form
char szMEDIUM[256]; // Medium
char szENGINEER[256]; // Engineer
char szTECHNICIAN[256]; // Technician
char szSOURCE[256]; // Source
char szCOPYRIGHT[256]; // Copyright
char szSOFTWARE[256]; // Software
char szCREATION_DATE[256]; // Creation Date
char szSUBJECT[256]; // Subject
char szCOMMENTS[256]; // Comments
char szNumExtraDatas[256];
char extra[256];
} MYOUTPUT;
MYINPUT is the same.
DWORD WINAPI FilterGetNextSpecialData(HANDLE hInput, SPECIALDATA * psp)
{ //return 0; // only has 1 special data! Otherwise we would use psp->hSpecialData
// as either a counter to know which item to retrieve next, or as a
// structure with other state information in it.
DWORD dwCount=(DWORD)psp->hSpecialData;
BOOL bContinue=TRUE;
char * pData=NULL; // Pointer to data
DWORD dwSuccess=1;
int i;
char tmp[48];
MYINPUT *mi;
mi=(MYINPUT *)GlobalLock(hInput);
while (bContinue)
{
bContinue=FALSE;
if (dwCount >= 8)
{
char * pData;
int i = (int)(dwCount - 8);
if ((i >= mi->szNumExtraDatas) || (!mi->extra[i].pData))
{
dwSuccess = 0;
break;
}
psp->dwExtra = (DWORD)-1; // so CEP handles this automatically
psp->dwSize = mi->extra[i].dwLength;
psp->hData = GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT, psp->dwSize+8);
pData=(char *)GlobalLock(psp->hData);
CopyMemory(pData, mi->extra[i].pData, mi->extra[i].dwLength);
lstrcpy(psp->szListType, mi->extra[i].szList);
lstrcpy(psp->szType, mi->extra[i].szType);
GlobalUnlock(psp->hData);
}
else switch (dwCount)
{
case 0:
if (!*mi->szTITLE)
{
bContinue=TRUE;
dwCount++;
break;
}
lstrcpy(psp->szListType,"WAVE");
lstrcpy(psp->szType,"DISP");
psp->dwExtra=1;
psp->dwSize=lstrlen(mi->szTitle)+1+4;
psp->hData=NULL;
pData=psp->szDataIn;
i=1;
CopyMemory(pData,&i,4);
lstrcpy(pData+4,mi->szTitle);
break;
case 1:
if (!*mi->szArtist)
{
bContinue=TRUE;
dwCount++;
break;
}
lstrcpy(psp->szListType,"INFO");
lstrcpy(psp->szType,"IART");
psp->dwExtra=1;
psp->dwSize=lstrlen(mi->szArtist)+1;
psp->hData=NULL;
pData=psp->szDataIn;
lstrcpy(pData,mi->szArtist);
break;
case 2:
if (!*mi->szAlbum)
{
bContinue=TRUE;
dwCount++;
break;
}
lstrcpy(psp->szListType,"INFO");
lstrcpy(psp->szType,"INAM");
psp->dwExtra=1;
psp->dwSize=lstrlen(mi->szAlbum)+1;
psp->hData=NULL;
pData=psp->szDataIn;
lstrcpy(pData,mi->szAlbum);
break;
case 3:
if (!*mi->szComment)
{
bContinue=TRUE;
dwCount++;
break;
}
lstrcpy(psp->szListType,"INFO");
lstrcpy(psp->szType,"ICMT");
psp->dwExtra=1;
psp->dwSize=lstrlen(mi->szComment)+1;
psp->hData=NULL;
pData=psp->szDataIn;
lstrcpy(pData,mi->szComment);
break;
case 4:
if (!*mi->szYear)
{
bContinue=TRUE;
dwCount++;
break;
}
lstrcpy(psp->szListType,"INFO");
lstrcpy(psp->szType,"ICRD");
psp->dwExtra=1;
psp->dwSize=lstrlen(mi->szYear)+1;
psp->hData=NULL;
pData=psp->szDataIn;
lstrcpy(pData,mi->szYear);
break;
case 5:
if (!mi->szTrackNumber)
{
bContinue=TRUE;
dwCount++;
break;
}
lstrcpy(psp->szListType,"INFO");
lstrcpy(psp->szType,"ISBJ");
psp->dwExtra=1;
wsprintf(tmp,"%d",mi->szTrackNumber);
psp->dwSize=lstrlen(tmp)+1;
psp->hData=NULL;
pData=psp->szDataIn;
lstrcpy(pData,tmp);
break;
case 6:
if (!mi->szGenre)
{
bContinue=TRUE;
dwCount++;
break;
}
lstrcpy(psp->szListType,"INFO");
lstrcpy(psp->szType,"IGNR");
psp->dwExtra=1;
if (mi->szGenre>126)
mi->szGenre=126;
lstrcpy(tmp,Genres[mi->szGenre]);
psp->dwSize=lstrlen(tmp)+1;
psp->hData=NULL;
pData=psp->szDataIn;
lstrcpy(pData,tmp);
break;
case 7:
{
char * pData;
if (!mi->pID3v2)
{
bContinue=TRUE;
dwCount++;
break;
}
psp->dwExtra = 1;
psp->dwSize = mi->dwSizeID3v2;
psp->hData = GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT, psp->dwSize+8);
pData=(char *)GlobalLock(psp->hData);
CopyMemory(pData, mi->pID3v2, mi->dwSizeID3v2);
lstrcpy(psp->szListType, "WAVE");
lstrcpy(psp->szType, "ID3x");
GlobalUnlock(psp->hData);
}
break;
default:
// all done!
dwSuccess=0;
break;
}
}
dwCount++;
psp->hSpecialData=(HANDLE)dwCount;
GlobalUnlock(hInput);
return dwSuccess;
}
DWORD WINAPI FilterGetFirstSpecialData(HANDLE hInput, SPECIALDATA * psp)
{
MYINPUT * mi;
DWORD dwSuccess=0;
BOOL bHasTagInfo = TRUE;
if (!hInput)
return 0; // return is boolean
mi=(MYINPUT *)GlobalLock(hInput);
psp->hSpecialData=(HANDLE)0; // start at the case 0: item in FilterGetNextSpecialData
GlobalUnlock(hInput);
if (bHasTagInfo)
return FilterGetNextSpecialData(hInput,psp);
else
return FALSE;
}
Trevor Scott Ph.D., MSc, Eng Hons.
|
|
|
|
|