|
|
Pasting text basically amounts to the following
if (OpenClipboard())
{
HANDLE hClipboardData = GetClipboardData(CF_TEXT);
char *pchData = (char*)GlobalLock(hClipboardData);
CString strFromClipboard = pchData;
GlobalUnlock(hClipboardData);
CloseClipboard();
Cheers,
Tom Archer
Inside C#, Extending MFC Applications with the .NET Framework
It's better to listen to others than to speak, because I already know what I'm going to say anyway. - friend of Jörgen Sigvardsson
|
|
|
|
|
Thanks a lot, that article did the trick.
Matt (Padawan Learner)
|
|
|
|
|
This seems to work...
CString CHTMLEditView::GetSelection(void)
{
IDispatch * pDocDisp = NULL;
IHTMLDocument2* pDoc;
IHTMLSelectionObject* pSelObj;
IHTMLTxtRange* pTxtRange;
CString cstext;
pDocDisp = GetHtmlDocument();
HRESULT hr = pDocDisp->QueryInterface( IID_IHTMLDocument2, (void**)&pDoc );
if (SUCCEEDED(hr)) {
hr = pDoc->get_selection(&pSelObj);
CComBSTR p;
pSelObj->get_type(&p);
if ((SUCCEEDED(hr))&&((p==L"Text")||(p==L"None"))) {
hr = pSelObj->createRange((IDispatch**)&pTxtRange);
if (SUCCEEDED(hr)) {
BSTR text;
pTxtRange->get_htmlText(&text);
cstext = text;
SysFreeString(text);
pTxtRange->Release();
}
pSelObj->Release();
}
pDocDisp->Release();
pDoc->Release();
}
return cstext;
}
To put a string back into the selection use pTxtRange->pasteHTML(text) instead of pTxtRange->get_htmlText(&text)
Niall.
|
|
|
|
|
i want to make a groupbox's title transparent,can I
|
|
|
|
|
Maybe I'm misunderstanding you. Why don't you just set it's text to a blank value if you simply don't want to see a text value?
Cheers,
Tom Archer
Inside C#, Extending MFC Applications with the .NET Framework
It's better to listen to others than to speak, because I already know what I'm going to say anyway. - friend of Jörgen Sigvardsson
|
|
|
|
|
I have gotten a path to a file as being '\Device\HarddiskVolume2\Program Files\Visual Assist.NET\vc7\VaCPPP.tmp'. I need to be able to convert it to 'c:\Program Files\Visual Assist.NET\vc7\VaCPPP.tmp', Is the original path that i have been given classed as a symbolic link, and if so how can i resolve this to a Drive Letter and Path. If it is not a symbolic link that what is it called or reffered to as.
Regards
Amleth
|
|
|
|
|
Amleth,
From the Windows XP Help Glossary:
An area of storage on a hard disk. A volume is formatted by using a file system, such as FAT or NTFS, and has a drive letter assigned to it. You can view the contents of a volume by clicking its icon in Windows Explorer or in My Computer. A single hard disk can have multiple volumes, and volumes can also span multiple disks.
The first name you have is not a symbolic link but the location of the file given the device name (\Device\HarddiskVolume2). The mapping of is recorded in the registry somewhere (under HKEY_LOCAL_MACHINE I think). The value is only registered if you have volumes enabled. If your right-click on a drive and go into properties. Select the hardware tab and then select the device and then properties again, you will see the volumes on the drive there recorded in the Volumes tab.
To get to this from C++ you will need to use one of the registry classes (I don't use them as I concentrate on Standard C++ so I can't advise further).
Hope this helps,
Jim Bannon
(When in doubt, try honesty!)
|
|
|
|
|
Hello all,
I know I've done this before, but my code notes don't reflect it, and I can't for the life of me remember how to do it. It's probably easy, but the easy solutions always illude me.
My app needs to either process data, or not process data at startup depending on a registry setting. The user is also able to stop or start the process via a menu item. If the process is started at startup, then the stop menu item needs to be enabled and the start menu item needs to be disabled. If the process is stopped at startup, then the opposite must occur in the menu's. The registry setting is read at startup.
Here's my questions:
1. Where does the registry read function go? OnCreateClient, or PreCreateWindow?
2. In the Update functions for each menu ie start process and stop process, how do I enable one and disable the other, and vice versa.
Thanks!
Frank
"Keyboard Error - Press F1 to Continue"
|
|
|
|
|
Process startup info on InitInstance. Enable/Disable menu items using the ON_UPDATE_COMMAND_UI macro
cheers,
Chris Maunder
|
|
|
|
|
Thanks Chris, I got it.
Frank
"Keyboard Error - Press F1 to Continue"
|
|
|
|
|
Frank Deo wrote:
1. Where does the registry read function go? OnCreateClient, or PreCreateWindow?
It depends on what kind of data you are reading (i.e. will it affect the window that you are about to display?)
The place where I usually initialize data is on the function that handles WM_CREATE, but you have other options such as InitInstance, OnInitialUpdate, (if dialog base OnInitDialog), etc.
Frank Deo wrote:
2. In the Update functions for each menu ie start process and stop process, how do I enable one and disable the other, and vice versa.
To enable or disable menu items you can have a look at ON_UPDATE_COMMAND_UI or ON_UPDATE_COMMAND_UI_RANGE. Also the CCmdUI class. You can also have a look at EnableMenuItem().
pCmdUI->Enable( TRUE ); // FALSE to disable
// Afterall, I realized that even my comment lines have bugs
When one cannot invent, one must at least improve (in bed).-My latest fortune cookie
|
|
|
|
|
Thanks Toni, between EnableMenuItem and pCmdUI->Enable() I figured it out.
Frank
"Keyboard Error - Press F1 to Continue"
|
|
|
|
|
You are welcome.
// Afterall, I realized that even my comment lines have bugs
When one cannot invent, one must at least improve (in bed).-My latest fortune cookie
|
|
|
|
|
I am implementing a namespace extension and I need to be able to determine what item is selected in the tree view (left hand pane in explorer) which is an IShellFolder implementation.
I can get the selection notification in the listview (right hand pane) in my implementation of IShellView via the IShellView's WndProc callback, but I can find no such mechanism in the IShellFolder.
Is there another interface in addition to IShellFolder that I need to implement in order to get this info or am I just missing something more obvious?
Many thanks!
Mike Hartway
|
|
|
|
|
I need to record a time from when a button was pushed to the end when the function has finished I would appreciate some help anyone?
[It is possible to represent everything in this universe by using 0 and 1]
I was born intelligent
Education ruined me!.
An idea is useless until it has been implemented.
|
|
|
|
|
get the timestamp time_t when the button is pressed, then the time_t at the end of the function, and do what most of us like to call subtraction to find the answer
time_t m_ltime;
void MyBla::OnButton()
{
time( &m_ltime );
}
void MyBla::Function()
{
time_t time_l;
time( &time_l );
long difference = time_l - m_ltime;
}
######### Here it is in milliseconds
DWORD m_dwTickCount;
void MyBla::OnButton()
{
m_dwTickCount = GetTickCount();
}
void MyBla::Function()
{
UINT difference = GetTickCount() - m_dwTickCount;
}
|
|
|
|
|
yes i already have a time capturer but i need a logging class or something to write to an external file.
[It is possible to represent everything in this universe by using 0 and 1]
I'm going to live forever or die trying.
|
|
|
|
|
it's only 1 int, just serialize it
|
|
|
|
|
I'm trying to figure out how to set the first view (i.e. Icon, List, Details, etc) that CFileDialog uses. It seems to always default to the List style.
I've looked at a some good articles on CFileDialog customization, including:
http://archive.devx.com/free/mgznarch/vcdj/1998/oct98/opensave1.asp
http://msdn.microsoft.com/msdnmag/issues/02/01/c/default.aspx
http://www.codeproject.com/dialog/customize_dialog.asp
and the closest I've come is with a simple class derived from CFileDialog with an over-ridden OnFolderChange(). It's necessary to use OnFolderChange() for the file list access because the list has not yet been initialized when OnInitDialog() is called, and OnFolderChange() is called at the very end of initialization.
void CNewFileDialog::OnFolderChange()
{
CWnd *pW = GetParent();
HWND hWndExplorer = FindWindowEx(pW->m_hWnd, NULL, L"SHELLDLL_DefView", NULL);
if ( hWndExplorer )
{
HWND hWndFileList = FindWindowEx(hWndExplorer, NULL, L"SysListView32", NULL);
if ( hWndFileList )
{
DWORD dwCurrentStyle = GetWindowLong(hWndFileList, GWL_STYLE);
if ((dwCurrentStyle & LVS_TYPEMASK) != m_DefaultStyle)
{
SetWindowLong(hWndFileList, GWL_STYLE, (dwCurrentStyle & ~(LVS_TYPEMASK | LVS_NOCOLUMNHEADER)) | m_DefaultStyle);
}
}
}
}
However, this code only works if the new default style is LVS_ICON, LVS_SMALLICON, or LVS_LIST. Of course, I'm really only interested in setting the default style to LVS_REPORT, but the dialog comes up with a completely empty file list. I think this is because the list headers have not been initialized, so simply changing the style doesn't work. I need to kick-off some kind initialization, or try some other approach.
Any other ideas?
Thanks
Peter
|
|
|
|
|
If it is a timing issue how about using PostMessage() to post a message to yourself which then changes the style.
I'd like to be able to remember and set the list control style in my custom File Open dialog in ED (see sig), but I didn't think this could easilly be done, and haven't tried. However I was thinking along the lines of hooking into the View Menu toolbar button and getting it to set the style to what I wanted. That may be another approach. I already hook the list control and go though all sorts of interesting hoops.
If you find a way to do this please let me know.
Neville Franks, Author of ED for Windows. Free Trial at www.getsoft.com
|
|
|
|
|
I did think of this approach, but I'm not sure how to do it. I'm actually new to Windows GUI programming, so I'm stumbling around in the dark a bit. What I have tried are WH_CALLWNDPROC hooks for both the toolbar button and the list control and watching all the messages that these controls received. Didn't get to far. Maybe someone has a better way...
|
|
|
|
|
|
As a software developer with an Electronic and Electrical ENgineering bacground, I always wanted to write device drivers and on Windows NT, 2000 and XP. I downloaded the DDK from MS but could not even write a single line of code despite being familiar with Win32 and MFC?
Where do I find a short and very goo tutorial and how do I get to write and run my codes from the Visual Studio Environment??
Thanks in advance.
Inyang Isaac
Isaac Inyang
Ansyl Technologies
|
|
|
|
|
I don't know anything about DDK but I since I wanted to learn how to use it a while ago, I have this link http://www.osronline.com[^].
I just have a question? Do you have to buy DDK because I can't find a link that lets you download it. On Microsoft's website there are links that tell you how to place orders and stuff. Is there a free version?
// Afterall, I realized that even my comment lines have bugs
When one cannot invent, one must at least improve (in bed).-My latest fortune cookie
|
|
|
|