|
DrawItem() is only called when items are to be drawn. If there are no items to draw, it's not called. You still have to add your items as normal.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Send this message from your dialog after doing AddString() to set LB_SETCOUNT...
lResult = SendMessage( // returns LRESULT in lResult (HWND)hWndControl, // handle to destination control
UINT) LB_SETCOUNT, // message ID
(WPARAM) wParam, // = (WPARAM) () wParam;
(LPARAM) lParam // = (LPARAM) () lParam; );
For example,
HRESULT lResult;
lResult = m_MyListBox.SendMessage( (UINT) LB_SETCOUNT,
(WPARAM) m_MyListBox.m_iTotalItemCount,
(LPARAM) 0);
where, m_MyListBox is member object of your Owner Draw ListBox derived class (like CMyListBox derived from CListBox). m_iTotalItemCount as WPARAM is total number of item data to be set. LPARAM can be sent as 0.
One thing needs to be taken into account that the LB_SETCOUNT works only when ListBox Style is "No Data" i.e. LBS_NODATA. Has Strings should be set as FALSE. Setting LB_SETCOUNT will call Draw Item.
Happy Programming
|
|
|
|
|
I have written a program which reads data from internet and displays it in the web browser control.
And now I'm fuzz about such problems( I have paste the code at the end):
Sometimes the 'DisplayInExplore' works well, but Sometimes it crashs.
1. I have debugged it , and found that 'pHD->write(pSFArray);' method would result in the 'Assert Debug' fatal error. And I can't step into the method write.
2. Sometimes, the 'pHD->write(pSFArray);' could execute successfully, but there was no data to display in the Web Browser control. And when cursor went into the client area of the Web Browser control, the cursor change to the 'wait' status.
So , I have no idea why it works so instable ? Or there are some errors in my function?
Plz give me some suggestion ,Thx.
---------------------------------------------------------------------------
The code is as below:
void CGameInfoDlg::DisplayInExplore(CString strContent)
{
//m_exploreView is the CWebBrowser2
IHTMLDocument2* pHD=(IHTMLDocument2*) m_exploreView.GetDocument();
VARIANT* pVATable=NULL;
SAFEARRAY* pSFArray;
pSFArray = SafeArrayCreateVector(VT_VARIANT, 0, 1);
if(pSFArray!=NULL && pHD!=NULL)
{
SafeArrayAccessData(pSFArray,(LPVOID*) &pVATable);
BSTR bstrContent=strContent.AllocSysString();
pVATable->vt=VT_BSTR;
pVATable->bstrVal=bstrContent;
SafeArrayUnaccessData(pSFArray);
pHD->write(pSFArray);
}
else
{
MessageBox("Errors!");
}
SysFreeString(pVATable->bstrVal);
if(pSFArray!=NULL)
{
SafeArrayDestroy(pSFArray);
}
}
|
|
|
|
|
who can give me some tins?? plz, thx very very very much....
|
|
|
|
|
Please ,how i can get serial numbers of bios, motherboard, processor,vedio card ,hard disk , with java or c programmes under windows and linux platforms
if u have any site or url contact me .
email
ss2006@caramaiol.com
am
-- modified at 7:06 Sunday 26th February, 2006
|
|
|
|
|
Hi, I'm new to parallel port and would like to ask a few questions:
1. I want to program the parallel port (in C) using VC++, how can I access the port?
2. How can I run my program in windows?
Your help is truly appreciated!
|
|
|
|
|
Hi,
Check this port programming[^].
The _inp and _outp are privileged instructions and cannot be used in Win2000 and WinXP. Try using some library. Check this link.
InpOut32.dll[^]
Bye,
Cool Ju
Dream Ur Destiny
|
|
|
|
|
I have used InpOut32.dll - really convenient to use, etc.
One thing to watch out for - I was doing InPorts, and got peculiar results until I realised that it returned an 8-bit value, and I wanted a 16-bit value, so I had to do 2 separate InPorts and combine the results.
|
|
|
|
|
We do not need to select palette into DC to display rich-colored bitmap for monitor if we set monitor properties as 32 bits or 16 bits.
but, do we need to select palette for Printer DC for printing rich-colored bitmap?
A nice tool for optimizing your Microsoft html-help contents.
Includeh10
-- modified at 9:23 Sunday 26th February, 2006
|
|
|
|
|
can anyone help me find how to write a program to read input from hardware temperature sensors and display it.
- Kyle
|
|
|
|
|
See http://www.wotsit.org
|
|
|
|
|
i could not find any helpful topics for this problem on that web site. if you could point me to the one you found it would help me out.
thank you
- Kyle
|
|
|
|
|
Hi Kyle
What do you fo exactly?
In the site helpful information for hardware,...
But if it's not your answer go to
http://www.codeguru.com/
Have a nice day
|
|
|
|
|
Hi,
I am developing a console type application that accepts command from the user and executes it, if it is valid.
This is a Dialog based application. I have only a CEdit control in this dialog box.
When this application starts, the focus is in the CEdit control and the entire initial text is selected.
How do i keep the focus without selecting the whole initial text. I tried to set selection in InitDialog. But things didnt work as I expected.
Please suggest me a solution for this
Thanks
Saravanan
|
|
|
|
|
Hi
Do you test WM_SETFOCUS
|
|
|
|
|
Hi,
After
1)seting focus to the edit control in the initdialog
2) send EM_SETSEL Message to that edit control with the info of setting the text.
3) return false in the initdialog.
Regards,
FarPointer
|
|
|
|
|
I have dialog (window/form) that inherits from the CDialog class. This dialog has various controls on it including a few buttons and textboxes.
I am trying to get some keyboard events (key presses) to fire some events but its not working.
In the Header file for the dialog i have this as a protected declaration
[code]
afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
[/code]
I have an ON_WM_KEYDOWN() event created and its corresponding method in the .cpp file
[code]
void COpenGLMFCDlg::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
[/code]
Within this method i have written some test code to change the text in a textbox just to see whether the event is fired correctly, but the text is never changed. I also tried changing the dialog's name and also firing some Message Boxes ... but nothing worked.
The code in the "OnKeyDown" method is as follows:
[code]
void COpenGLMFCDlg::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags){
switch(nChar)
{
case VK_RETURN:
SetWindowText("You pressed Enter");
break;
case VK_F1:
SetWindowText("Help is not available at the moment");
break;
case VK_DELETE:
//SetWindowText("Can't Delete This");
//AfxMessageBox("Testing");
m_Txt_Test.SetWindowText("The Event was fired");
break;
case VK_DIVIDE:
//SetWindowText("Testing");
m_Txt_Test.SetWindowText("Another Event fired");
break;
default:
SetWindowText("Whatever");
}
}
[/code]
Could someone please (pretty please) tell me why this isn't working and whether i have done all that is needed for a keyboard event to fired & a result to be seen on screen.
Thanks in advance.
|
|
|
|
|
Hello braveheartkenya ,
If you have each control's in the form then WM_KEYDOWN and UP isn't work and All Event's(WM_KEYDOWN and Up) send
to controls unless in the form non controls
|
|
|
|
|
So how do i put the focus on the Dialog itself rather than on a control. The focus is currently on a button and i would like to put it on the dialog so that the events will be sent there.
|
|
|
|
|
I think It's not possible.
I suggestion for example:
delete all controls in the from(the form is empty) I think now WM_KEYDOWN is work.
or
if you need to controls in the form you can create controls in the application
Example:
Like this for each control
//////////////in the Header file//////////////////////
#define IDC_BUTTON1 1000
....
class CMyCpp: public CDialog
{
...
...
...
DECLARE_MESSAGE_MAP()
CButton m_Button;
afx_msg void OnBnClickedButton();
};
/////////In the cpp file/////////
void CMyCpp::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_BUTTON1, m_Button);
}
BEGIN_MESSAGE_MAP(CMyCppCDialog)
ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton)
END_MESSAGE_MAP()
BOOL CMyCpp::OnInitDialog()
{
m_Button.Create("MyButton",WS_CHILD|WS_VISIBLE...,CRect(0,0,100,25),this,IDC_BUTTON1);
CDialog::OnInitDialog();
}
void CMyCpp::OnBnClickedButton()
{
}
|
|
|
|
|
Thanks for the idea ... i'll try it out
|
|
|
|
|
I know how to load and save info to files but I'm having trouble loading info from a file into multiple strings. This is the data that I am saving and it works just as I want it to.
ofstream fp;
fp.open("C:\\war\\stringdata.DAT", ios::out);
for (count = partytotal -1; count >= 0; count--)
for (count2 = 16; count2 >= 0; count2--)
{
fp << party[count][count2];
fp << "\n";
}
fp.close();
Party is defined as: CString party[4][17];
I'm not a vary good programmer , so could anyone give me an example of code that will load the data back into the strings . (nothing I tried worked)
Thank you.
"To an optimist the glass is half full.
To the pessimist the glass is half empty.
To the programmer the glass is twice as big as it needs to be."
GC13: "Mature-Ages 16 and up. 'your mature, right?'"
FARGORE: "no, but I am over 16."
|
|
|
|
|
I'm experiencing some problems with writing data to a driver of mine and I was wondering if it is caused by the following:
I open a single handle to the driver with CreateFile(). I use the handle in both ReadFile() and WriteFile() which are called in separate threads.
Now, what I'm wondering is if this approach has some multithreading issues (because both threads use the same handle) and if I should instead open two handles to the driver.
Thanks!
|
|
|
|
|
Sorry I'm probably roung here but have you tried using the /FORCE command line for the multithreading?
"To an optimist the glass is half full.
To the pessimist the glass is half empty.
To the programmer the glass is twice as big as it needs to be."
GC13: "Mature-Ages 16 and up. 'your mature, right?'"
FARGORE: "no, but I am over 16."
|
|
|
|
|
I am not quite sure what that has to do with the question, though..
|
|
|
|