|
I'm using STL vector to store file names as I retrieve them from FindNextFile() but when I try to access different locations in the vector, they all return the last file added. Am I storing or accessing incorrectly?
<br />
vector<char *> file_names;<br />
<br />
HANDLE Hnd;<br />
WIN32_FIND_DATA WFD;<br />
<br />
Hnd = FindFirstFile( "*.175", &WFD);<br />
file_names.push_back(WFD.cFileName);<br />
int i=0;<br />
while ( FindNextFile( Hnd, &WFD) ) {<br />
file_names.push_back(WFD.cFileName);<br />
cout << file_names[i] < endl;
i++;<br />
}<br />
for(int i=0; i <=file_names.size(); i++) {<br />
cout << file_names[i] << endl;<br />
cout << file_names.at(i) << endl;<br />
}<br />
<br />
vector <char *>::iterator f;<br />
for ( f = file_names.begin(); f != file_names.end(); f++)<br />
cout << *f << endl;<br />
|
|
|
|
|
The vector holds a set of pointers.
One solution is to copy the actual file name to a string container and then store it in the vector.
Kuphryn
|
|
|
|
|
kiken wrote:
file_names.push_back(WFD.cFileName);
Think about what that is doing. It's storing the address of the cFileName array over and over. You need to store copies of each name as they are returned. One way to do that is to use a vector<string>
--Mike--
The Internet is a place where absolutely nothing happens.
-- Strong Bad
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|
|
Hi
I have a simple problem regarding toolbars here.
When we create a new SDI project, the codes for the standard toolbar is there. The toolbar will appear and disappear gracefully when we check the function inside the menu. But when i add a new toolbar, how do i make it appear and disappear gracefully ??
I try to use the "ShowWindow(SW_HIDE)" but the ugly gray patch is still there!
Thanx you for ur kind attention !!
bk
|
|
|
|
|
not sure what you are you are describing but the code below seems to work for me.
m_wndMyToolBarName.ShowWindow(SW_HIDE);
RecalcLayout();
|
|
|
|
|
Hi ROK
Really thanx a lot !! Meanwhile i also found another method using
ShowControlBar(&m_WndToolBar, true, false);
bk
|
|
|
|
|
Thanks bk.. Never really had to hide a toolbar in an app before.. so my previous post was the first thing I came up with that worked.. thnks for posting the correct way.
|
|
|
|
|
Let Suppose I have a Frame Window
and this frame is split into to panes
now in each pane is another frame.
How do I get the top level menu to route message commands to the other two frames? I can use classwizard all day long to create message ID's in the other two frames.. but no matter how hard I press that left mouse button.. the message is never delivered.
|
|
|
|
|
Look in the MSDN for OnCmdMsg(). It takes care of command routing. Override it to give your sub-frames a look at the messages before processing them in the normal way.
he he he. I like it in the kitchen! - Marc Clifton (on taking the heat when being flamed)
NEW: Awasu 1.0[^]: A free RSS reader with support for Code Project.
|
|
|
|
|
From article:
http://www.codeproject.com/dll/plug-in.asp#xx88311xx
Serialize problem only appear with VC7.0,it works fine with vc6.0.
I have been somewhat successful in trying to implement serialization for my test app. I am using a CList template to store objects. Here are a few
details...
Serialization works just fine for documents saved and reloaded during a given session. This includes data stored in dialog resources. This is as long as I serialize the list then walk through the list, serializing each list object.
However, Serialization fails after closing the session and then reopening. In general, I am given only the {DllProxy} class (where I should be getting my dll's runtime class instead) and all other vars are mud.
I AM able to successfully serialize save/load a list of the DLLProxy "pointers" themselves with great fidelity. But the Plug_Object "pointers" that they originally created are lost from session-to-session.
Thanks and Best Regards
|
|
|
|
|
If I am right, you doing a mod of my article. If you can it would be best if you could send a copy of the offending code to me to have a look at. If you do, try and keep it as minimal as possible, so that it just illustraits the problem.
The only other issue is that I work with VC 6 only, so if its dieing in VC7 only, I may not be able to spot/replicate the problem.
Roger Allen
Sonork 100.10016
Were you different as a kid? Did you ever say "Ooohhh, shiny red" even once? - Paul Watson 11-February-2003
|
|
|
|
|
Hi all,
i have a problem with this piece of code:
bool CBaseWin::createWin()
{
//Create the application's window
m_hWnd = CreateWindow(m_pAppName,
m_pAppTitle,
WS_OVERLAPPEDWINDOW,
50,
50,
500,
500,
NULL,
NULL,
m_hInstance,
this);
return (m_hWnd != NULL);
}
m_hWnd will always be 0 if i include the "this" pointer as the last parameter, if i substitute NULL for it, it will work and return a value for m_hWnd.
This is from the tutorial located here:
http://www.codeproject.com/useritems/win32windowwrapperclass.asp
Can anyone explain why the inclusion of the "this" pointer causes CreateWindow to fail?
PS. The error code is 1400 - which is invalid window handle.
Regards,
Skute
|
|
|
|
|
You are missing a parameter - either lpClassName or lpWindowName.
|
|
|
|
|
I have been asked to provide a spin control for a tab control which has the standard 'left/right' buttons and also 'first/last' button. Without having to implement a fully owndrawn tab control.
Any suggestions would be gratefully appreciated.
|
|
|
|
|
Hi, In Developer Studio (VC++ ver 4.0),I used to have an "H" button (to switch to the respective header file) above the workspace source file window. It seems to have disappeared recently, and I don't know how to get it back again !!! Anybody got any idea on how I do this ??? (I can't see anythingin "Help" that covers this - most annoying !!!)
Doug
|
|
|
|
|
O.K. -within 2 minutes of posting this message, I solved my own problem !!! (typical !) The .clw file was missing - when I had recreated it, the "H" button reappeared magically !! (Hope this may be of some help to someone in the future !)
Doug
|
|
|
|
|
I have an application based on the CListView class, and I'd like to do the following: when a user resizes the frame of my application, I'd like the columns in the list view to resize themselves appropriately. My problem is that I'm a little confused as to when (and where) I do this.
Currently, I am handling the WM_SIZE method in the view class. Here is the code I'm using (in the OnSize() method):
CListView::OnSize(nType, cx, cy);
if(m_List->GetSafeHwnd() != NULL)
{
CRect rectList;
m_List->GetClientRect(&rectList);
int listwidth = (rectList.Width() - GetSystemMetrics(SM_CXVSCROLL));
int nColInterval = listwidth / 10;
m_List->SetColumnWidth(0, 4 * nColInterval);
m_List->SetColumnWidth(1, listwidth - (4 * nColInterval));
} I have several problems with this code. When the vertical scroll bar actually does appear, the column sizes aren't quite right. I want a space in the header control for the vertical scroll bar's top arrow (hence the GetSystemMetrics() call above). But when the vertical scroll bar shows up, it looks like twice the distance is inserted in the header control.
Another problem is that when I switch from any non-details view to the details view, the size is not updated initially. So, for example, if I'm in "Large Icons" mode and resize the window, then switch to "Details" mode, the columns are sized for the previous window size, not the current size.
Can anyone shed any light on what I should do for this? Any help would be greatly appreciated!
Thanks,
Jonah Bishop
Visit JGB Productions
|
|
|
|
|
|
Hello,
I have a problem in win32 app.
How can I use MFC Great classes in win32 application ?
They conflict in header file: "afx.h" & "windows.h"
Thank for your response
|
|
|
|
|
|
Thank you Nishant
|
|
|
|
|
The release exe works fine. The debug is crashing at the calll to CDialog Create()
BOOL CDisplayInfoList::Create(UINT nID, CWnd *pWnd, const CString* keys, int keysSize, std::set<CString>* pKeySet)
{
m_pParentWnd = pWnd;
m_pKeySet = pKeySet;
m_allKeysArray = new CString [keysSize];
m_arraySize = keysSize;
for (int i =0; i < keysSize; i++)
{
m_allKeysArray[i] = keys[i];
}
<code>return CDialog::Create( nID,pWnd);</code>
}
Its just a popup resizing dialog with a clistctrl and two buttons.
What shall I suspect? THe call is :
CDisplayInfoList* pDisplayInfoList = new CDisplayInfoList;
if (pDisplayInfoList == NULL) return;
<code> BOOL ret = pDisplayInfoList->Create(IDD_DISPLAYINFOLIST, this, goodFields, flds.size() ,&(pDoc->m_keySet));</code> if(!ret)
{
AfxMessageBox("Error creating viewbox");
delete pDisplayInfoList;
return;
}
winocc.cpp line 259, where its saying its not IsWindow:
int CWnd::GetDlgCtrlID() const
{
ASSERT(::IsWindow(m_hWnd));
|
|
|
|
|
sorry its line 279...in
void CWnd::MoveWindow(int x, int y, int nWidth, int nHeight, BOOL bRepaint)
{
ASSERT(::IsWindow(m_hWnd));
if (m_pCtrlSite == NULL)
::MoveWindow(m_hWnd, x, y, nWidth, nHeight, bRepaint);
else
m_pCtrlSite->MoveWindow(x, y, nWidth, nHeight, bRepaint);
}
and stops in this if I set a breakpoint in it....
|
|
|
|
|
I made a new identical class but named its resource and classname shorter. One of the two factors (maybe both) made the debug version happy too. I didnt realize there was a limit to the length of the names????
|
|
|
|
|
Hi everyone!
I'm creating a Dialog based Win32 Application. One of my controls is a picture control.
How can i load and display an image(bitmap) on this control???
Should I subclass the picture control???
Please send an example if you can!...
Thanks!!!
|
|
|
|