|
Ahhhh, Thanxs a lot !
Marco
|
|
|
|
|
I have a control which contains an array of CDialogs. They can be expanded or collapsed. When expanded, and if there are many of them, there is a strong need for a scroll bar. We've implemented a scroll bar and the functionality is great, but the drawing/redrawing makes it look pretty bad.
It's a kind of list control... When the items are collapsed, they are only a few pixels in height. When the user expands any of them, a gap is inserted after that item - enough to draw in the dialog which it represents... It's basically an enhanced version of the "Rollup Control" found at:
RollupCtrl Article
Currently, we're using MoveWindow() for each item. We've tried using DeferWindowPos to speed things up/improve the drawing... but it's made no difference
You can see the control by downloading an exe I uploaded just now:
Click to download the zip file (39k)
I've posted on various forums, and haven't had anyone even attempt to provide a solution. There must be something obvious I'm missing out...
Thanks in advance....
|
|
|
|
|
Draw the dialogs onto a seperate bitmap, then copy that bitmap onto your DC in one go.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
Christian Graus wrote:
Draw the dialogs onto a seperate bitmap, then copy that bitmap onto your DC in one go.
do you mean, cause all the DCs to be pointing to ONE "memDC" ?
Jason
|
|
|
|
|
I meant drawing them yourself. Otherwise, stopping them from calling OnEraseBackground is also a good idea.
Christian
No offense, but I don't really want to encourage the creation of another VB developer. - Larry Antram 22 Oct 2002
Hey, at least Logo had, at it's inception, a mechanical turtle. VB has always lacked even that... - Shog9 04-09-2002
During last 10 years, with invention of VB and similar programming environments, every ill-educated moron became able to develop software. - Alex E. - 12-Sept-2002
|
|
|
|
|
When moving a lot of windows around, I have found a main problem of flickering to be the cause of OnEraseBkgnd(). I n the past I have solved this by exlcuding the area of the controls that are shown from the erase area like this:
BOOL CSGAControlView::OnEraseBkgnd(CDC* pDC)
{
static int dont_erase_indexes[] =
{
IDC_STANDARDS_TRAY_SGA,
IDC_STANDARDS_TRAY_LDA,
IDC_THUMB1,
IDC_THUMB5,
IDC_THUMB2,
IDC_THUMB6,
IDC_TRAY1_TEXT,
IDC_TRAY2_TEXT,
IDC_TRAY3_TEXT,
IDC_TRAY4_TEXT,
IDC_TRAYNAME4,
IDC_TRAYNAME3,
IDC_TRAYNAME2,
IDC_TRAYNAME1
} ;
CRect clip ;
for (int i = 0 ; i < sizeof(dont_erase_indexes) / sizeof(int) ; i++)
{
if (GetDlgItem(dont_erase_indexes[i])->GetStyle() & WS_VISIBLE)
{
GetDlgItem(dont_erase_indexes[i])->GetWindowRect(&clip);
ScreenToClient(&clip);
pDC->ExcludeClipRect(&clip);
}
}
pDC->GetClipBox(&clip);
pDC->FillSolidRect(clip, GetSysColor(COLOR_BTNFACE));
return FALSE;
}
I havn't been able to run your example exe as I don't have gdiplus, but hopefully this is releated to your problem.
Roger Allen
Sonork 100.10016
I have a terminal disease. Its called life!
|
|
|
|
|
This is very interesting - I look forward to trying it out.
Thanks!
Jason
|
|
|
|
|
I understand this requires two bytes instead of just one byte as compared to ascii, but how would I implement unicode in a control like an edit control...?
Does the system do this automatically if you switch your locale settings...?
It must do this, otherwise if I passed 4 bytes to say DrawText() or TextOut() and expected something like farsi output I would actually get 4 ascii characters instead...???
Just curious...
Thanx!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
Hockey wrote:
your locale settings...?
Your locale settings is never unicode. That's a codepage (usually 1252, and it covers standard 0-127 ASCII codes, plus 128-255 local-specific codes).
Hockey wrote:
DrawText() or TextOut()
DrawTextW()
TextOutW()
In other words, without explicitely compiling with the _UNICODE switch (not possible on W9X by the way), DrawText() and TextOut() will be mapped to the local WIN32 DrawTextA() and TextOutA() implementation.
How low can you go ? (MS rant)
|
|
|
|
|
.S.Rod. wrote:
Your locale settings is never unicode. That's a codepage (usually 1252, and it covers standard 0-127 ASCII codes, plus 128-255 local-specific codes).
Interesting...atleast now I have some understanding as to how UNICODE works...
Thanx
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
|
imariano wrote:
use COM
??? How, I thought the only way was to use unicows.lib ?
Max.
|
|
|
|
|
Oops, I didn't mean to put that blurb about COM in there 8)
You might be able to get away with a Unicode-internal COM component, since COM passes BSTR ings around. But it's the long way around, I think, and you still will not get full a Unicode API set on 9x/ME.
"The greatest danger to humanity is humanity without an open mind." - Ian Mariano
http://www.ian-space.com/
|
|
|
|
|
If you want to use Unicode ina window like and Edit box, you would simply use CreateWindowW to create the Edit box instead of CreateWindowA. When you compile your app, if you set the program to compile unicode, it will automatically map all of the functions like CreateWindow to CreateWindowW or DrawText to DrawTextW.
However a Unicode app will not work on Win9x unless you have the layer for Unicode installed on that machine.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Thanx for the reply
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
I download a view class and attach it to a CMDIChildWnd class.
when I use like this:
CMultiDocTemplate* pDocTemplate;
pDocTemplate = new CMultiDocTemplate(
IDR_RESOURCE,
RUNTIME_CLASS(CMyDoc),
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
RUNTIME_CLASS(CMyView));
AddDocTemplate(pDocTemplate);
The view class does well.When I resize the CChildFrame,the view also resizes.I think this is normal use.
Now I don't want to use CMyDoc.I use CreateNewChild to create
CMyFrm class,which is created by instructions mentioned in microsoft kb Q201045.Every thing is good until I show the view first like this:
void CMyFrm::ActivateFrame(int nCmdShow)
{
// TODO: Add your specialized code here and/or call the base class
CRect clientRect;
this->GetClientRect(&clientRect);
m_pView = new CMyView();
if(! m_pView->Create(NULL, NULL, WS_VISIBLE |WS_CHILD, clientRect,this, 1234))
{
TRACE( "Failed view creation\n" );
return ;
}
CMDIChildWnd::ActivateFrame(nCmdShow);
}
Now then I resize the CMyFrm,I clicke the max icon ,the frame maximizes,but the view leaves unchanged.I trace the program and find when I click the max icon,the onsize event of view doesn't trigger.
Any help will be appreciated!
|
|
|
|
|
While rendering the display for a edit control if I use variable width fonts like MS Sans Serif ???
Does this mean i'd have to calculate the position of the caret each keypress rather than just calculate the width once say during OnSetFont() while using a fixed width font like Courier New ...?
Thats seems a little over kill, but I guess nessecary if I want to support variable width fonts also...?
Thanx!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
hi experts
i like to display the printer properties information in controls of my dialog box. how can i fetch that values. if i use DocumentProperties with DM_IN_PROMPT attribute it displays the corresponding properties window of the printer. Instead of displaying that i want to read that setting and place values in my own dialog controls. I mean what kind of papersizes it supports, page orientation and etc.how can i acheive this please help me
from
venu
|
|
|
|
|
In order to know whether a dial-up client is still
connected to the server, i use gethostbyaddr() passed with client's IP
(which is dynamic)in the server program to
check (this is for the case that the client closes(or
drops accidentally) the dial-up connection without
closing the socket connection in advance; if client closes
the socket connection, the server is able to know that).
But i get error with code 11004, which i believe is
something about dababase. My question is: can i use
gethostbyaddr() in the server program to check client's
abnormal disconnetion? if so, what's wrong with my method?
if not, what would be the proper way?
Thanks a lot!
Wenrich
|
|
|
|
|
Wenrich wrote:
My question is: can i use
gethostbyaddr() in the server program to check client's
abnormal disconnetion?
no. check if the socket is still connected
|
|
|
|
|
In the Unix world, you'd use select() . In windows you can use the same API, select()[^] or WSAAsyncSelect()[^].
Using plain old select() , you'd test your exceptfds' with the FD_ISSET() macro to check if an exception occured with a socket.
Alternatively, you could just send() or recv() from the socket and check the return value of WSAGetLastError() for what you need.
NOTE: The Microsoft Berkley Socket implementation send() and recv() block, the WSA equivalents provide several alternatives which allow sending a message to a window when socket events occur (probably a better bet for you, if you aren't too deep with Unix-style sockets.)
-- ian
"The greatest danger to humanity is humanity without an open mind." - Ian Mariano
http://www.ian-space.com/
|
|
|
|
|
I have for the last few hours hacked endlessly at the CEdit control...i'v subclassed the control in question and tried overriding it's message handling switch code with my own and I still can't quite get it do do things that I want without serious overhaul...
Syntax hilighting, line numbers and such...
Anyways my quesiton is this...I need a editor to work on relativley small files...all web based langs like PHP,ASP,HTML,XML,JScript all of which I always try and make smaller than 64K in size (including comments) I find it's hard for me to keep organized when files grow larger than this anyways...
Sorry I went off topic there a bit...
My question: ( I already am familiar with the classes available on CP )
Because I wanna make the assumption no more memory than 64K
or I guess 65535(FFFF) bytes will ever be needed would it be acceptable for me to do the following for memory allocation...? Sure it wastes memory sometimes, but I don't think it'll get fragmented because it's prolly all allocated in one linear array of bytes...
char m_arrBytes[0xFFFF];
I would prefer to use this instead of new/delete or malloc and similar c functions...
No need to ever worry about leaks...no fragmentation...
I'm just wondering if I maybe missed something...other than extensibility...remember i'm very confident that FFFF bytes is enough for all web based project files. Besides it would force good programming practice (IMO) keeping your files small
Opinions...???
despite the fact i'm prety dead set on using this approach...perhaps you can change my mind if you bring something to my attention I didn't already know..
Then I would really appreciate your help...
Thanx!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
what are you more specific questions?
|
|
|
|
|
Anonymous wrote:
what are you more specific questions?
None...thats it...I wasn't looking for answers just opinions...if you know something I don't or that maybe I missed...I would just like to hear it...
Like maybe:
char m_arrBytes[0xFFFF];
can get fragmented under certain circumstances...I dunno although I seriously 100% dought it
This is all I wanted to know
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|
|
Now I can write data from program to text file by using WriteString() and SeekToEnd().
So I want to write program to copy all data within first text file to second text file by using CStdioFile
Do you know how to do that?
Thank you for your answer.
These below is some part of my program to write data from program to text file by using CStioFile
outp_filename = m_uniquecodeFileName;<br />
<br />
CStdioFile EncryptedUniqueCode;<br />
CFileException FileExc;<br />
UINT nOpenFlags;<br />
CString szTemp, m_string;<br />
nOpenFlags = CFile::modeWrite;<br />
if (!EncryptedUniqueCode.Open(outp_filename, nOpenFlags, &FileExc)) {<br />
FileExc.ReportError();<br />
return;<br />
}<br />
EncryptedUniqueCode.SeekToEnd();<br />
<br />
.<br />
.<br />
.<br />
<br />
EncryptedUniqueCode.WriteString(m_string+'\n');<br />
<br />
EncryptedUniqueCode.Close();
|
|
|
|