|
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
|
|
|
|
|
Btw, happy festival of lights. (I think it was yesterday.)
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Your BOOL idea works great! Why didnt my GetSafeHwnd idea work? Isnt it equivalent? Whats the subtle difference between your approach and mine?
Happy Lights to you too! I lose track of these things - though my mom is a real surfer and keeps me informed via email. They have one of those webTV thingies...
Appreciate your help,
ns
|
|
|
|
|
You were checking that the view was valid. But the controls within the form view may not get completely set up until the view is shown. OnInitialUpdate() catches the initial display, hence the bool guarantees that all is well.
ns wrote:
They have one of those webTV thingies...
I'm so jealous! I set up my dad with a laptop and internet service, but he's so busy taking care of mom that he has no time to use it. Sad, 'cos he's such a gadget fan and at 83 has the wherewithall of a young man.
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
I put the BOOL as false in the constructor. How come the constructor runs even if view2 hasnt been spawned yet? I can see that it would get set to TRUE in OnInitDialog(), but at what stage does the constructor run? I have a SwitchView function in my MDI app which either creates if necessary, the view, or else it just switches.
CView* pView;
POSITION pos;
pos = pDoc->GetFirstViewPosition();
while( pos != NULL )
{
pView = pDoc->GetNextView( pos );
if( pView->IsKindOf( pViewClass ) )
{
pView->GetParentFrame()->ActivateFrame();
return TRUE;
}
}
pChild = (CMDIChildWnd*) pTemplate->CreateNewFrame(pDoc, NULL );
Which line runs the constructor?
Another very puzzling fact is that even though I hadnt run SwitchView, pView still came out to be nonNUll in my debugging......pos wasnt NULL....
Appreciate your help,
ns
|
|
|
|
|
The view might be created (constructed) when it's added to the multi doc template. Btw, tell me you meant OnInitialUpdate() , not OnInitDialog() , right?
/ravi
Let's put "civil" back in "civilization"
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Yeh u want RemoveAll if it is a CList???
|
|
|
|
|
Hi,
I receive from a Barcode Reader a string with a end of message character LF, TAB+, ENTER, RETURN, CR/LF in an editbox.
For example : *B00001*+<cr> or *B00001*+<enter>, ...
When I receive the string and the End of Message is RETURN, CR, ENTER, the program is closed. Ok I use Pretranslate Message for inhibit.
But when I would like to use TAB+ or LF nothing. I listen a BEEP.
My question is :
I would like when the Editbox detect the End of Message from the Barcode Reader, I execute a command.
Best Regards,
youssef
|
|
|
|
|
How to do this by using SQL-DMO? Subscriber and publisher status must be known.
I keep submitting “VB” as a Priority-1 bug, but apparently no one here knows how to fix it. Nick Hodapp, Semicolon
|
|
|
|
|
Hi!
In a system that has full memory protection, what are the way that allow user application to communicate with function inside the OS???
Thanks
|
|
|
|
|
You do it with system calls. Basically a system call is a "software interrupt" that get fired off from a user process, which is intercepted by the kernel of the OS to do work on behalf of the user.
What OS? Google[^]
|
|
|
|
|
Consider the following (i've cut things for brevity)...
using namespace Gdiplus;
CImageList img;
img.Create(IDB_USERBUTTONS,32, 52, RGB(192,192,192));
CLSID bmpClsid;
if (GetEncoderClsid(L"image/bmp", &bmpClsid) == -1)
{
ASSERT(FALSE);
}
IMAGEINFO *i;
for (long t = 0; t < numbuttons; t++)
{
HICON bibi = ImageList_img.ExtractIcon(t);
HICON bibi2 = CopyIcon(bibi);
Bitmap image(btn.GetIcon());
s = image.Save(name.AllocSysString(), &bmpClsid, NULL);
}
So, in effect, I'm trying to use the Bitmap class' constructor to load an image from a HICON which itself derives from an ImageList (ExtractIcon). However, although this should work (and i can use the HICON on a button for example) the Bitmap constructor simply blows up, trashes the stack and leaves me with nothing useful to work with. Passing a HICON from an icon resource... works. Why?
It seemed like a fine idea to parse an imagelist into a bunch of disk-based image files...
Tim Stubbs
|
|
|
|
|
Hi!
Could anyone tell me why disabling interupts to achieve mutual exclusion is not acceptable on a multiprocessor sytem???
Thanks
|
|
|
|
|
Well, the first thing that springs to mind is that you can't arbitrate access to any external shared resources with this method e.g. shared RAM. However, the use of something like a Semaphore in the context of a multi-processor kernel would allow this. In general, it is always best to think twice about disabling interrupts to implement mutual exlusion since any time spent in this state will increase interrupt latency - which may not be desirable.
Phil
|
|
|
|
|
Hi
I want to bring up a dialog box when a button is clicked.I'm having problems getting the dialog box to appear when I click on the file.
My code is:
void CMainFrame::OnSFile() <br />
<br />
{ <br />
<br />
m_chatterChooser.DoModal(); <br />
}
And I've declared in the header:
CDialog m_chatterChooser;
Is this correct?
Thank you.
|
|
|
|