Click here to Skip to main content
15,920,031 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: TT font from file Pin
Chris Losinger7-Jul-02 6:48
professionalChris Losinger7-Jul-02 6:48 
GeneralPDF format Pin
ivex7-Jul-02 1:02
ivex7-Jul-02 1:02 
GeneralRe: PDF format Pin
Venet7-Jul-02 3:42
Venet7-Jul-02 3:42 
GeneralRe: PDF format Pin
8-Jul-02 17:09
suss8-Jul-02 17:09 
GeneralHide icon on taskbar Pin
overflow6-Jul-02 22:06
overflow6-Jul-02 22:06 
GeneralRe: Hide icon on taskbar Pin
Rickard Andersson206-Jul-02 23:50
Rickard Andersson206-Jul-02 23:50 
GeneralRe: Hide icon on taskbar Pin
lwglucky7-Jul-02 3:43
lwglucky7-Jul-02 3:43 
Generalusing OpenClipboard() right after keybd_event Pin
Otyug6-Jul-02 21:05
Otyug6-Jul-02 21:05 
This one has been driving me mad for hours. I should have stopped to ask for help a long time ago.

Under certain circumstances I am unable to open the clipboard after using keybd_event to send a synthesized ctrl-c keystroke. (here's how i'm using keybd_event)

// sent ctrl-c
keybd_event(VK_CONTROL, 0, 0, 0);
keybd_event('C', 0, 0, 0);
keybd_event('C', 0, KEYEVENTF_KEYUP, 0);
keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);

if (OpenClipboard())
...etc


The circumstances under which OpenClipboard fails is if I have previously opened the clipboard and have "pasted" text into it with the CopyStringToClipboard() function below. (Here are both of the clipboard functions i'm using)

void CClipboardDlg::CopyCurrentClipboardText()
{
	
	if (OpenClipboard()) 
	{
		HANDLE hClipboardData = GetClipboardData(CF_TEXT);
		char * pchData = (char*)GlobalLock(hClipboardData);
		CString strFromClipboard = pchData;
		GlobalUnlock(hClipboardData);	
		CloseClipboard();
        }
}
<BR><BR>

void CClipboardDlg::CopyStringToClipboard()
{
	CString strData;
	m_ClipboardStringList.GetText((m_iClipboardListPosition), strData);
	
	if (OpenClipboard())
	{
		if (::IsClipboardFormatAvailable(CF_TEXT)|| 
                    ::IsClipboardFormatAvailable(CF_OEMTEXT))
		{
			HGLOBAL hClipboardData;
			EmptyClipboard();
			hClipboardData = GlobalAlloc(GMEM_DDESHARE, strData.GetLength() + 1);
			char * pchData;
			pchData = (char*)GlobalLock(hClipboardData);
			strcpy(pchData, LPCSTR(strData));
			GlobalUnlock(hClipboardData);	
			SetClipboardData(CF_TEXT, hClipboardData);
		}

	     CloseClipboard();
	}

}


The strange thing is before I ever call CopyStringToClipboard() I can open the clipboard before and after the keystroke just fine. After calling CopyStringToClipboard() I can open the clipboard fine before sending the keystroke but not afterward. Stranger still, if I send the keystroke twice (not in code, but say, by a registered hotkey that calls the function) then it works fine for the second and for every subsequent keystroke until I call CopyStringToClipboard() again! It's only that first keystroke after calling CopyStringToClipboard() that behaves badly.

My first suspicion was I wasn't allowing enough time between sending the keystroke and attempting to open the clipboard but I found that waiting 5000 ms was the minimum time until the clipboard could be opened. That is beside the fact that everything works fine until CopyStringToClipboard() gets called.

I eagerly await enlightenment with my open hand poised in front of my forehead and the word "DOH" on the tip of my tongue.
GeneralSet new Password in existing Dao Database's Pin
6-Jul-02 20:16
suss6-Jul-02 20:16 
GeneralRe: Set new Password in existing Dao Database's Pin
7-Jul-02 15:44
suss7-Jul-02 15:44 
GeneralRe: Set new Password in existing Dao Database's Pin
Cursoe12-Jul-02 3:12
sussCursoe12-Jul-02 3:12 
GeneralNewbie Question Pin
6-Jul-02 18:43
suss6-Jul-02 18:43 
GeneralRe: Newbie Question Pin
adara6-Jul-02 19:30
adara6-Jul-02 19:30 
GeneralRe: Newbie Question Pin
Venet7-Jul-02 3:49
Venet7-Jul-02 3:49 
GeneralRe: Newbie Question Pin
Scot T Brennecke7-Jul-02 11:35
Scot T Brennecke7-Jul-02 11:35 
GeneralRe: Newbie Question Pin
[James Pullicino]7-Jul-02 22:11
[James Pullicino]7-Jul-02 22:11 
GeneralGetting system info Pin
fhpratti6-Jul-02 16:43
fhpratti6-Jul-02 16:43 
GeneralRe: Getting system info Pin
Scot T Brennecke7-Jul-02 11:03
Scot T Brennecke7-Jul-02 11:03 
GeneralRe: Getting system info Pin
generic_user_id7-Jul-02 11:17
generic_user_id7-Jul-02 11:17 
GeneralRe: Getting system info--For Remote System Pin
7-Jul-02 22:50
suss7-Jul-02 22:50 
QuestionAnyone know how to get an object spinning on its own axis? Pin
Alan Chambers6-Jul-02 9:43
Alan Chambers6-Jul-02 9:43 
GeneralTransparentBlt has problem on Win98 !!! Pin
Hadi Rezaee6-Jul-02 8:49
Hadi Rezaee6-Jul-02 8:49 
GeneralRe: TransparentBlt has problem on Win98 !!! Pin
PJ Arends7-Jul-02 14:02
professionalPJ Arends7-Jul-02 14:02 
GeneralRe: TransparentBlt has problem on Win98 !!! Pin
Hadi Rezaee8-Jul-02 8:55
Hadi Rezaee8-Jul-02 8:55 
Generalmapping modes spaghetti Pin
6-Jul-02 4:37
suss6-Jul-02 4:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.