|
Set the menu item resource ID to the same value.
|
|
|
|
|
Thanks!
Appreciate your help,
ns
|
|
|
|
|
Worked great! It took care of the OnUpdate function as well.....is that expected? So basically it ran both OnEdit and OnUpdateEdit().....
Appreciate your help,
ns
|
|
|
|
|
If your speaking of the ON_UPDATE_COMMAND_UI() message. Yes, thats expected. That is expected of any message you handle. If two controls have the same ID, it will handle them with the same function.
|
|
|
|
|
Thats the function I was talking about. Thanks. The changes took no time and were painless with your idea!
Appreciate your help,
ns
|
|
|
|
|
I've been referring to the article here on win32 serial comms. Im building a link to perform just one character(1 byte) transmission/reception via the serial port. I managed to get the send(WriteFile) working, but the receiver just doesnt seem to work, nor does it give an error. This is the code im using for the receive character function.
void CBuggyControllerDlg::OnRec() <br />
{<br />
<br />
UpdateData(TRUE);<br />
if((ReadFile(handlePort_,&recd,1,&length,NULL))==0)<br />
{AfxMessageBox("No Data on Input Serial Buffer");}<br />
else{<br />
m_strlistupdate=recd;<br />
m_list.InsertString (0, _T(m_strlistupdate));}<br />
<br />
}
The function is called only after a byte has been sent and hence no monitoring of the port is necessary, although i imagine a loop would be needed. When i send a byte to this programs serial port, and then click recieve{OnRec() }, it doesnt give an error, nor does it display the right character. Could somebody please help me? I have set all the dcb config, including the one for flow control. Send Data works perfectly.
|
|
|
|
|
On second thought, it might be working except for the fact that i might be messing up my strings. The buffer for readfile/writefile needs to be a void* hence i declared recd as BYTE recd; . Now how does one make the character thats been stored in recd , into a string, or make m_strlistupdate take the value of recd ?
The serial readfile could probably be wrong, but i just noticed this. Please let me know if you find errors in the code.
Thanks!
|
|
|
|
|
Anyone know any tricks for displaying a context menu when the left mouse button clicks the status bar?
|
|
|
|
|
You could subclass from CStatusBar and handle WM_LBUTTONDOWN and WM_LBUTTONUP .
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Yeah, I was trying to stay away from that.. I was hopeing to catch a message inside main frame.. I may just create a CStatusBar Class.. It would probably be easier.
Thanks!
|
|
|
|
|
I have a 2d array that I'd like to display in a colored grid. The colors on the grid would be based on the contents of the array. There would be 1 grid square for each point in the array.
Example:
I have int grid_data[ 3 ][ 3 ], I'd want to display a grid like
. . . .
. . . .
. . . .
. . . .
And would like to be able to change the colors of each point easily.
What's the best way to do this?
Thanks
|
|
|
|
|
The easiest way is to use a grid control like MSFlexGrid.
Thanks for the help,
Bill
|
|
|
|
|
I know this is a lot to ask from strangers but any help would be appreciated. I am currently trying to recreate or modify the program here (this is the source <http://www.installsite.org/files/HTMLautoplaySrc.zip>). It is an executable that is used for launching a html page on a CD automatically (autorun). It reads options from an ini/inf file and opens the htm in a html control. I have at this point managed to recreate the application to about 95% completeness, but I found that mine has the same problem as the original. My htm page that is displayed contains a Flash file (swf) that has buttons with links to other htm/swf pages that are local (on the CD). If you launch one of these pages and it opens over the original window AND you close the new window BEFORE it finishes loading, the original page does not repaint. In other words it just shows white where the window was open over it. This also happens sometimes if you minimize the window then restore it again. If you let the new window load entirely everything works fine most of the time. I need to get this fixed. I am at an intermediate level (mostly self taught) of C++.
Thanks,
Steve
PS. I am willing to supply sample documents if you think it is the htm/swf causing the problem instead of the html control.
|
|
|
|
|
<br />
CString m_n, m_e, n_str, e_str; <br />
int n_strlen, e_strlen;<br />
UINT k_keyID;<br />
<br />
m_Proc.GetInfo(FileName, n_str, e_str, n_strlen, e_strlen, k_keyID);<br />
<br />
m_n = n_str;<br />
m_e = e_str;<br />
These above is somepart of my code. m_Proc is object and call function GetInfo which have 5 function parameters (FileName, n_str, e_str, n_strlen, e_strlen, k_keyID)
These below is detail of GetInfo function
<br />
void CExtract::GetInfo(const CString& m_FileName, CString n_str, CString e_str, int n_strlen, int e_strlen, UINT keyID)<br />
{<br />
n_str ="1234";<br />
e_str = "578756";<br />
n_strlen = 4;<br />
e_strlen = 6;<br />
keyID = 48756;<br />
}<br />
but when I see n_str value after exit GetInfo function. I see n_str = {""}
e_str = {""}
I expect n_str = {"1234"} , e_str = {"578756"}
Do you know how to solve my problem?
Thank you for your answer.
|
|
|
|
|
You're passing in parameters by value, which means you can alter them locally (in your function) but they won't be written to. You can use CString& (CString references), and int pointers, so you'd modify your program accordingly:
void CExtract::GetInfo(const CString& m_FileName, CString& n_str, CString& e_str, int* n_strlen, int* e_strlen, UINT* keyID)
{
n_str ="1234";
e_str = "578756";
*n_strlen = 4;
*e_strlen = 6;
*keyID = 48756;
}
m_Proc.GetInfo(FileName, n_str, e_str, &n_strlen, &e_strlen, &k_keyID);
You should probably do checks to make sure no NULL pointers are getting passed in, or just create an info class or structure to use, and pass that back and forth.
|
|
|
|
|
Hi
I know how to save strings to a file using MFC and without MFC (file streams).
But i would like to know how i can save integers and floats and BYTEs and other things like that. I mean,.. i just used to convert them to a string and save them that way but that actually takes up more space in the end so it seems. So how do i save them binary? like... an integer is 4 bytes right? how do i save it to a file so it only takes up 4 bytes? Same for a float..
Thank you.
Kuniva
--------------------------------------------
|
|
|
|
|
3 suggestions: serialize, serialize, serialize. See this[^] article.
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Thanks!!!
Great article btw
Kuniva
--------------------------------------------
|
|
|
|
|
It's only a sample...
typedef struct
{
DWORD Version;
DWORD QueryPosition;
DWORD GridPosition;
DWORD ChartPosition;
DWORD NotePosition;
BOOL IsStatic;
}HEADER;
HEADER header;
header.Version = (DWORD)1.0;
header.QueryPosition = 1230;
header.GridPosition = 0;
header.ChartPosition = 0;
header.IsStatic = TRUE;
pFile.Open(strFileName, CFile::typeBinary | CFile::modeCreate | CFile::modeWrite);
pFile.Write(&header, sizeof(HEADER));
Regards
Carlos Antollini.
Pi Five[^]Creator
Sonork ID 100.10529 cantollini
|
|
|
|
|
If you're using file streams, just pass them in
ofstream fs("c:\myfile.txt");
fs << "This is a string " << 42 << 'a' << 9.627;
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
|
|
|
|
|
The release version works fine. In the debug version it crashes.
I do this:
POSITION pos = pDoc->GetFirstViewPosition();
while (pos!=NULL)
{
CDlgLists* pView = (CDlgLists*)(pDoc->GetNextView(pos));
ASSERT_VALID(pView);
pView->m_list1.DeleteAllItems();
pView->PostMessage(WM_COMMAND, IDC_BUTTONHIDEV2,0);
}
Crashes at pView->m_list1.DeleteAllItems(); in
_AFXCMN_INLINE BOOL CListCtrl::DeleteAllItems()
{ ASSERT(::IsWindow(m_hWnd)); return (BOOL) ::SendMessage(m_hWnd, LVM_DELETEALLITEMS, 0, 0L); }
Why does release work? How can I make the debug work as well?
Appreciate your help,
ns
|
|
|
|
|
ns wrote:
{ ASSERT(::IsWindow(m_hWnd)); return (BOOL) ::SendMessage(m_hWnd, LVM_DELETEALLITEMS, 0, 0L); }
Seems that you dont have a valid window handle there. I would guess that your pView->m_list1 member is not more valid.
In release builds you will send a message to a non-existant window, which is not much of a problem for windows. But in the debug build, the ASSERT() checks for this condition, because obviously something is wrong in your code. Set a breakpoint in the while() loop and check the pView and m_list1 variables.
I keep submitting “VB” as a Priority-1 bug, but apparently no one here knows how to fix it. Nick Hodapp, Semicolon
|
|
|
|
|
pView was not NULL. But I didnt know how to check to see if m_list1 is Not NULL since it crashes at that line..Is that what I am to do? Hover over m_list1 and see if its something not 0?
Appreciate your help,
ns
|
|
|
|
|
Andreas is right. But to answer the question "How can I make the debug work as well" here's a suggestion:
- Add a public
bool m_bInitialized member to your CDlgLists class and set it to false in the view's constructor.
- Override
CView::OnInitialUpdate() and set m_bInitialized to true .
- Modify the problem code to check if
m_bInitialized is true before mucking with the view's controls. /ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Okay. That sounds good. I see that pView is not Null. I just tried:
POSITION pos = pDoc->GetFirstViewPosition();
while (pos!=NULL)
{
CDlgLists* pView = (CDlgLists*)(pDoc->GetNextView(pos));
ASSERT_VALID(pView);
<code>if(NULL != pView->m_list1.GetSafeHwnd())</code>
{
pView->m_list1.DeleteAllItems();
pView->PostMessage(WM_COMMAND, IDC_BUTTONHIDEV2,0);
}
}
but it still crashes. Now I'll try your idea...
Appreciate your help,
ns
|
|
|
|