Click here to Skip to main content
15,914,165 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Vc++ pore toolkit Pin
Cedric Moonen22-Feb-07 3:30
Cedric Moonen22-Feb-07 3:30 
AnswerRe: Vc++ pore toolkit Pin
Hamid_RT22-Feb-07 0:47
Hamid_RT22-Feb-07 0:47 
QuestionDrag and Drop Pin
Try21-Feb-07 22:19
Try21-Feb-07 22:19 
AnswerRe: Drag and Drop Pin
prasad_som22-Feb-07 3:00
prasad_som22-Feb-07 3:00 
AnswerRe: Drag and Drop Pin
Arman S.22-Feb-07 4:51
Arman S.22-Feb-07 4:51 
QuestionRe: Drag and Drop Pin
Mark Salsbery22-Feb-07 5:47
Mark Salsbery22-Feb-07 5:47 
AnswerRe: Drag and Drop Pin
Try22-Feb-07 16:55
Try22-Feb-07 16:55 
QuestionProblem drawing inside a dialog box [modified] Pin
jones16621-Feb-07 22:08
jones16621-Feb-07 22:08 
I need to draw some Unicode text with ScriptString API inside a dialog box.

I tried using these functions inside dialog procedure's WM_INITDIALOG:
WCHAR g_szCurrentString[30] =
{
	'H', 'e', 'l', 'l', 'o',
	0x064a, 0x064f, 0x0633, 0x0627, 0x0648, 0x0650, 0x064a, 
	'W', 'o', 'r', 'l', 'd',
	0	
};


SCRIPT_STRING_ANALYSIS GetStringAnalysis(HDC hdc, WCHAR *wstr, UINT wlen)
{
	SCRIPT_CONTROL			scriptControl = { 0 };
	SCRIPT_STATE			scriptState   = { 0 };
	SCRIPT_STRING_ANALYSIS	scriptStringAnalysis;

	ScriptStringAnalyse(
		hdc,
		wstr,
		wlen,
		wlen * 2,
		-1,				// Unicode string
		SSA_GLYPHS|SSA_FALLBACK,
		0,				// no clipping
		&scriptControl,
		&scriptState,
		0,
		0,
		0,
		&scriptStringAnalysis
	);

	return scriptStringAnalysis;
}

void Uniscribe_TextOut(HDC hdc, int xpos, int ypos, int selstart, int selend)
{
	SCRIPT_STRING_ANALYSIS ssa = GetStringAnalysis(hdc, g_szCurrentString, lstrlen(g_szCurrentString));

	if(selend < selstart)
	{
		int t = selstart;
		selstart = selend;
		selend   = t;
	}

	ScriptStringOut(
		ssa,
		xpos,
		ypos,
		0,
		NULL,
		selstart,
		selend,
		FALSE
	);

	ScriptStringFree(&ssa);
}
void PaintWnd(HWND hWnd)
{
	PAINTSTRUCT ps;
	RECT	rect;
	HDC		hdcMem;
	HBITMAP hbmMem;

	BeginPaint(hWnd, &ps);

	GetClientRect(hWnd, &rect);

	//
	//	Create memory-dc for double-buffering
	//	(StringStringOut flickers badly!!)
	//
	hdcMem = CreateCompatibleDC(ps.hdc);
	hbmMem = CreateCompatibleBitmap(ps.hdc, rect.right, rect.bottom);
	SelectObject(hdcMem, hbmMem);
	//SelectObject(hdcMem, g_hFont);

	//	paint the text
	FillRect(hdcMem, &rect, GetSysColorBrush(COLOR_WINDOW));
	Uniscribe_TextOut(hdcMem, XBORDER, YBORDER, nSelStart, nSelEnd);

	// copy to window-dc
	BitBlt(ps.hdc, 0, 0, rect.right,rect.bottom, hdcMem, 0, 0, SRCCOPY);

	// cleanup
	DeleteObject(hbmMem);
	DeleteDC(hdcMem);
	EndPaint(hWnd, &ps);
}


Code is btw from http://www.catch22.net/tuts/zips/scriptstring.zip/

It works fine in main window (WM_PAINT), but something is wrong with dialogs. I tried replacing ps.hdc with GetDC(dialogHwnd) too. Should I draw inside an owner-drawn element?


Thanks. Smile | :)

-- modified at 7:33 Thursday 22nd February, 2007
QuestionRe: Problem drawing inside a dialog box Pin
prasad_som22-Feb-07 1:29
prasad_som22-Feb-07 1:29 
AnswerRe: Problem drawing inside a dialog box Pin
jones16622-Feb-07 1:53
jones16622-Feb-07 1:53 
GeneralRe: Problem drawing inside a dialog box Pin
prasad_som22-Feb-07 2:47
prasad_som22-Feb-07 2:47 
QuestionWho to make a package ? Pin
Suresh H21-Feb-07 21:57
Suresh H21-Feb-07 21:57 
AnswerRe: Who to make a package ? Pin
prasad_som21-Feb-07 22:07
prasad_som21-Feb-07 22:07 
GeneralRe: Who to make a package ? Pin
Suresh H21-Feb-07 22:15
Suresh H21-Feb-07 22:15 
AnswerRe: Who to make a package ? Pin
toxcct21-Feb-07 22:11
toxcct21-Feb-07 22:11 
GeneralRe: Who to make a package ? Pin
Suresh H21-Feb-07 22:17
Suresh H21-Feb-07 22:17 
GeneralRe: Who to make a package ? Pin
Rajesh R Subramanian21-Feb-07 23:33
professionalRajesh R Subramanian21-Feb-07 23:33 
AnswerRe: Who to make a package ? Pin
Hans Dietrich21-Feb-07 22:13
mentorHans Dietrich21-Feb-07 22:13 
GeneralRe: Who to make a package ? Pin
Suresh H21-Feb-07 22:15
Suresh H21-Feb-07 22:15 
GeneralRe: Who to make a package ? Pin
toxcct21-Feb-07 22:18
toxcct21-Feb-07 22:18 
AnswerRe: Who to make a package ? Pin
Hamid_RT22-Feb-07 0:20
Hamid_RT22-Feb-07 0:20 
QuestionRe: Who to make a package ? Pin
David Crow22-Feb-07 2:37
David Crow22-Feb-07 2:37 
AnswerRe: Who to make a package ? Pin
Mark Salsbery22-Feb-07 5:50
Mark Salsbery22-Feb-07 5:50 
QuestionMS Speech SDK: No sound can be heard while a .wav file being processed? Pin
chocm21-Feb-07 21:10
chocm21-Feb-07 21:10 
GeneralRe: MS Speech SDK: No sound can be heard while a .wav file being processed? Pin
Programm3r22-Feb-07 3:08
Programm3r22-Feb-07 3:08 

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.