Click here to Skip to main content
       

C / C++ / MFC

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page  Show 
GeneralRe: Methods bank accountmemberMagda634713 Mar '13 - 11:36 
No need to apologize I pity people like you who waste energy on trying to degrade people rather than help them. Rose | [Rose]
Questionread text filememberpeoria1237 Dec '12 - 9:59 
I want to read text file into edit boxses
e.g 10 string present in a text file. I have 10 edit boxes on dialog. how i can read that 10 string into edit box?
 
Thanks.
AnswerRe: read text filememberAndré Kraak7 Dec '12 - 20:56 
You can use the std::getline[^] for reading lines from a file.
Input/Output with files[^] explains how to work with files.
0100000101101110011001000111001011101001

AnswerRe: read text filemembersajeesh.c9 Dec '12 - 21:05 
I think first you should add a button in dialog and on handle of this button write the code below
void CReadFileDlg::OnReadFile() 
{
    CEdit* m_EditArray[10];
    CStringArray FileArray;
    char cTemp[256];
    ifstream fin;
    fin.open( _T("C:\\FileRead.txt"), ios::in|ios::nocreate );
    while( !fin.eof() )
    {
        // The getline function is used to read an entire line
        fin.getline( cTemp, 256, '\n' );
        CString csChartoString;
        csChartoString.Format( "%s", cTemp );
        if( csChartoString != "" )
        {
            FileArray.Add( csChartoString );
        }
     }
    int top = 10;
    int bottom = 30;
    for(int i = 0; i < 10; i++)
    {
        m_EditArray[i] = new CEdit;
        DWORD dwStyle = WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON;
        m_EditArray[i]->Create(dwStyle, CRect(10,top,100,bottom), this,100+i);
        m_EditArray[i]->ShowWindow(TRUE);
        top += 30;
        bottom += 30;
    }
    int nArraySize = FileArray.GetSize();
    int nPos = 0;
    for( int nIdx= 0; nIdx < nArraySize; ++nIdx )
    {
        m_EditArray[nIdx]->SetWindowText( FileArray.GetAt( nIdx ));
    }
}

QuestionWM_DEVICECHANGE sets wParam to unexpected value of 7 - how to troubleshoot this?memberVaclav_Sal7 Dec '12 - 4:10 
<b>In process / progress of being solved</b>
 
WM_DEVICECHANGE sets wParam to DBT_DEVNODES_CHANGED to update list (tree?) nodes.
No other info is available then. I have not retrieved any device list, so it is useless for me.
 
To receive DBT_DEVICEARRIVAL it is necessary to first use   RegisterDeviceNotification.
 
At this point no other help is required.
Thanks
Vaclav
 

 
I need some help / hints with implementing   WM_DEVICECHANGE in MFC Document /View setup.
I have managed to intercept the WM_DEVICECHANGE in   CmainFrame message map and process it .
The problem m is that the wParam is nowhere near the 0x8xxx, but it is plain “7” and the lParam is 0.
 
I went thru the Dbt.h and cannot figure out what is the   wParam = 7 telling me.
 
Here is the code snippet and if it is not formatted to you liking – I am sorry , but I write my stuff in OpenOffice and than copy it to CodeProject so it cannot be formatted properly.
 
<b>I just need some troubleshooting pointer / suggestion how to analyze these mysterious parameters. </b>
 
Maybe CmainFRame is not the place to start, but I got same parameters values when I used Cdialog message map directly.

Any help is as always appreciated.
Cheers
Vaclav
 
     ON_MESSAGE(WM_DEVICECHANGE, OnMyDeviceChange)
 
bool   CMainFrame::OnMyDeviceChange(WPARAM wParam, LPARAM lParam)
{
     TRACE("\nLRESULT CMainFrame::OnMyDeviceChange(WPARAM wParam, LPARAM lParam)");
     TRACE("\nwparam %i ",wParam);
     TRACE("\nlParam %i ",lParam);
      AfxMessageBox("!!!! CMainFrame::Device detection ");
      // pass WM_HARDWARE to view
      GetActiveView()->PostMessage(WM_HARDWARE,wParam,lParam);
….
 

Addendum
JUst found this info, so the additional question is - is CMainFrame "top window" and if not will RegisterDeviceNotification solve this ? I shall try it next.
 

The DBT_DEVICEARRIVAL and DBT_DEVICEREMOVECOMPLETE events are automatically broadcast to all top-level windows for port devices. Therefore, it is not necessary to call RegisterDeviceNotification for ports, and the function fails if the dbch_devicetype member is DBT_DEVTYP_PORT.
AnswerRe: WM_DEVICECHANGE sets wParam to unexpected value of 7 - how to troubleshoot this?memberJochen Arndt7 Dec '12 - 5:56 
It is the DBT_DEVNODES_CHANGED[^] event.
 
Your code and text can be formatted properly. It must be done manually after pasting (it does not care if pasting from OpenOffice or a plain text editor but you should remove HTML tags when pasting from Ooo). Select text with mouse and use the buttons above the edit window to apply specific formatting. If you know HTML, you may also type the HTML tags. Check the preview to see how it looks.
AnswerRe: WM_DEVICECHANGE sets wParam to unexpected value of 7 - how to troubleshoot this?memberjeron17 Dec '12 - 5:59 
See here [^]about halfway down.
 
From MSDN:
DBT_DEVNODES_CHANGED
A device has been added to or removed from the system.

GeneralRe: WM_DEVICECHANGE sets wParam to unexpected value of 7 - how to troubleshoot this?memberVaclav_Sal7 Dec '12 - 6:58 
Thank you, obviously I have not look all the way to the end of the page!
 
However, what the dickens is " ring3 people" note talking about?
So when "new node is detected / chaged"   is not same as
 
DBT_DEVICEARRIVAL   A device has been inserted and is now available.
 

Mr MS - I am not sure this note is in English!
 
and to get the device more work is necessary???
I am not sure I can figure that out, getting tired of this USB mess.
 

 

 
/*
* Message = WM_DEVICECHANGE
* wParam   = DBT_DEVNODES_CHANGED
* lParam   = 0
*
*         send when configmg finished a process tree batch. Some devnodes
*         may have been added or removed. This is used by ring3 people which
*         need to be refreshed whenever any devnode changed occur (like
*         device manager). People specific to certain devices should use
*         DBT_DEVICE* instead.
*/
#define DBT_DEVNODES_CHANGED                  0x0007
AnswerRe: WM_DEVICECHANGE sets wParam to unexpected value of 7 - how to troubleshoot this?mvpRichard MacCutchan7 Dec '12 - 21:51 
Vaclav_Sal wrote:
I write my stuff in OpenOffice and than copy it to CodeProject so it cannot be formatted properly.
Of course it can be formatted properly, just select all the code and use the code link above the edit window, or manually put a <pre lang="c++"> tag in front of it, and a </pre> tag at the end.
One of these days I'm going to think of a really clever signature.

GeneralRe: WM_DEVICECHANGE sets wParam to unexpected value of 7 - how to troubleshoot this?memberVaclav_Sal9 Dec '12 - 5:47 
Thank you, you are right.
Vaclav

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


Advertise | Privacy | Mobile
Web01 | 2.6.130523.1 | Last Updated 24 May 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid