|
can i specify baud rate 244 to operate the serial port with control Mscomm.ocx?
thx.
|
|
|
|
|
No, only 110, 300, 600, 1200, etc.
|
|
|
|
|
You said to use an IShellFolder pointer, but how do i get the IShellFolder interface for the folder that pNewId is pointing to in the
pFolder->Next(1, &pNewId, &pActual) loop?
void AddFilesFromFolder(ITEMIDLIST *pIdl)
{
if (pIdl)
{
IShellFolder *pBrowse = NULL;
LPENUMIDLIST pFolder = NULL;
LPMALLOC pMalloc = NULL;
ITEMIDLIST *pNewId = NULL;
STRRET strDispName;
LVITEM lvItem;
RECT rMain;
RECT rAdd;
char szCurrentFile[MAX_PATH+1+5];
char szFolderPath[MAX_PATH+1];
DWORD pActual = 0;
DWORD dwAttrib;
IShellFolder *CurrentFolder;
HRESULT err;
err = SHGetDesktopFolder (&CurrentFolder);
if (err == NOERROR)
{
SHGetMalloc(&pMalloc);
CurrentFolder->BindToObject(pIdl, NULL, IID_IShellFolder, (LPVOID*)&pBrowse);
pBrowse->GetDisplayNameOf(pIdl, SHGDN_INFOLDER, &strDispName);
err = pBrowse->EnumObjects(NULL, SHCONTF_FOLDERS | SHCONTF_NONFOLDERS | SHCONTF_INCLUDEHIDDEN, &pFolder);
if (err == NOERROR)
{
SHGetPathFromIDList(pIdl, szFolderPath);
lvItem.mask = LVIF_IMAGE | LVIF_TEXT;
while (pFolder->Next(1, &pNewId, &pActual) != S_FALSE)
{
dwAttrib = SFGAO_FOLDER;
pBrowse->GetAttributesOf(1, (LPCITEMIDLIST*)&pNewId, &dwAttrib);
if (!(dwAttrib & SFGAO_FOLDER))
{
pBrowse->GetDisplayNameOf(pNewId, SHGDN_INFOLDER, &strDispName);
PathCombine(gszPath, szFolderPath, strDispName.cStr);
GetID3();
FillInfo();
ListAddItem();
}
if (dwAttrib & SFGAO_FOLDER)
{
pBrowse->GetDisplayNameOf(pNewId, SHGDN_INFOLDER, &strDispName);
AddFilesFromFolder(pNewId);
}
}
pMalloc->Free(pNewId);
pMalloc->Release();
gbFileOpen = true;
pFolder->Release();
}
CurrentFolder->Release();
}
}
}
Thankyou
|
|
|
|
|
OK, I'm tearing my hair out over this one...
I've got a project with 2 .cpp files, both of which #include a .h file. All is well in the world. I add a second .h file (4dlist.h), for a template class. All is still well in the world. I then add a new .cpp file, with the single line #include "4DList.h", and now I start getting wierd compile errors.
So to recap, I have the following files:
CenFilter.cpp
CenWriter.cpp
foo.cpp
CenFilter.h
4DList.h
when foo is empty, everything works. when #includes 4DList.h I get errors.
here is the start of 4dlist.h:
template <class TYPE> class C4DList
{
public:
C4DList( UINT MaxSize = 1000 );
virtual ~C4DList();
C4DList( const C4DList &Copy );
void operator=( const C4DList &op2 );
UINT GetSize(){return m_ListSize;}
void AddTail( TYPE *pData );
TYPE *GetAt( UINT index );
void RemoveAt( UINT index );
void RemoveCurrentIt();
void RemoveAll();
void DeleteAllData();
void ItStart();
TYPE *ItNext();
...
...
...
So CenFilter.h has #include 4dlist.h and is fine.
but if foo.cpp has the single line it throws up:
Compiling...
foo.cpp
C:\Pete\Capture\CenFilter\CenReadFilter\4dlist.h(12) : error C2629: unexpected 'class C4DList<type> ('
C:\Pete\Capture\CenFilter\CenReadFilter\4dlist.h(51) : see reference to class template instantiation 'C4DList<type>' being compiled
C:\Pete\Capture\CenFilter\CenReadFilter\4dlist.h(12) : error C2238: unexpected token(s) preceding ';'
C:\Pete\Capture\CenFilter\CenReadFilter\4dlist.h(51) : see reference to class template instantiation 'C4DList<type>' being compiled
C:\Pete\Capture\CenFilter\CenReadFilter\4dlist.h(17) : error C2146: syntax error : missing ';' before identifier 'GetSize'
...
...
Now I REALLY don't get this. Oh, BTW, this isn't a standard appwizard project, it's adapted from an MSDN sample project.
I hope someone can help!
Pete
|
|
|
|
|
oops, I forgot about the <> thing
the first line of that code snippet should've been
template < class TYPE > class C4DList
sorry!
|
|
|
|
|
Not sure if this is your problem, but you have to include <windows.h> for UINT and other such types to be defined.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I don't think that's it, coz my other .cpp and .h files have UINT's in them
Thanks anyway
|
|
|
|
|
Give it a try, it's safer than guessing.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
OK, I think that was the best advice I've had in a few months
Next time I won't make any dumb assumptions. Or rather, I'll try not too.
I guess that the other .cpp files were including something else which eventually included windows.h
Thanks a lot Joaquin, I was starting to lose hope back there
Pete
|
|
|
|
|
I'd say 90% of debugging nightmares stem from false assumptions like "it can't be that because I know it works" and things like that. Happy programming
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I want when I run my program ,I get the handle of window opened behind it,I use this code but it does not work,Can anybody tell me whats the problem with this:
hwnd = ::GetForegroundWindow();
hwnd = ::GetNextWindow( hwnd , GW_HWNDNEXT );
::SetForegroundWindow(hwnd);
Mazy
"The more I search, the more my need
For you,
The more I bless, the more I bleed
For you."The Outlaw Torn-Metallica
|
|
|
|
|
Hi everyone,
I know this will not be a tough one for you guys... I'm doing a Win32 Application I was trying to extract a string on a string but String.H is limitted I need more advance parsing like MID Function, I cant use CString.H since my project is notMFC, is there another way around that I can extract a string from a string by specifying the offsets and the length? I tried to use this code:
lpAlpha1 = DynamicData; //Just showing to you that I search a dynamic string....
StartPos = 0;
EndPos = 0;
strLen = strlen(lpAlpha1);
while (StartPos < strLen){
EndPos = strcspn(lpAlpha1," "); //Problem
for(i=StartPos,j=0;i<=EndPos;i++,i,j++){
searchStr[j] = lpAlpha1[i];
}
searchStr[j]='\0';
....Search the searchstring in the database..
StartPos = EndPos;
}
cout << searchStr;
But this code post a problem on the strcspn function since I can's specify which offset should it start looking for the space to get the next word on the string.
I hope you understand my explanation, Please help me on this one.
Thanks/Regards
Sidney
Thanks/Regards
Sidney
|
|
|
|
|
If you decide to switch to std::string s (which I highly recommend), then substr works like a charm for extracting substrings much like MID$ in BASIC does.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi Joaquin,
ummm... I can't quite understand the use of this, do you have a very sample code that can shoe on how to use this? Please if you have kindy send me a copy, I do not know how to use this.
Thanks/Regards
Sidney
|
|
|
|
|
Sure:
std::string str1="Hello miserable world";
std::str2=str1.substr(6,9);
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
string::SubStr does the same thing as CString::Mid
Consult MSDN for more info.
|
|
|
|
|
You can use that CRT strstr function (you can a pointer to the string tu substact and then you do a strncpy to copy into another string the string found. Anyway I would recommand std::string better.
Best regards,
Alexandru Savescu
|
|
|
|
|
If you already know MFC's CString, then just use WTL which has its own CString.
--Mike--
Just released - RightClick-Encrypt - Adds fast & easy file encryption to Explorer
Like the Google toolbar? Then check out UltraBar, with more features & customizable search engines!
My really out-of-date homepage
Sonork-100.10414 AcidHelm
|
|
|
|
|
Hi,
I have a function that loads a file from harddisk. I'd like to add a second function that loads the file from the resource. How do I get a pointer to the data and the size of it?
<br />
BOOL LoadTGA(char* filename, char** ptr);<br />
BOOL LoadTGA(UINT nIDResource, char** ptr);
thx, Moak
|
|
|
|
|
HINSTANCE hInstance = LoadLibrary(pDLLPath);
HINSTANCE hInstance = AfxGetInstanceHandle();
HRSRC hRsrc;
if (hRsrc = FindResource(hInstance, pResourceName, pResourceType))
{
HGLOBAL hGlobal = LoadResource(hInstance, hRsrc);
if (hGlobal)
{
BYTE *pImage = (BYTE *)LockResource(hGlobal);
DWORD dwSize = SizeofResource(hInstance, hRsrc);
.... whatever
UnlockResource(hGlobal);
FreeResource(hGlobal);
}
}
(src)
-c
Cheap oil. It's worth it!
|
|
|
|
|
looks easy now
|
|
|
|
|
I always get an error when doing this procedure "The parameter is invalid.", here's how i call it. (pIdl is an ITEMIDLIST retrieved by calling SHBrowseForFolder, ghWnd is the handle to my window, and pNewId is modified by the EnumIDList->Next procedure)
IShellFolder *pBrowse = NULL;
IShellFolder *CurrentFolder = NULL;
ITEMIDLIST *pNewId;
char szFolderPath[MAX_PATH+1];
char szCompletePath[MAX_PATH+1];
WCHAR szTemp[MAX_PATH+1];
STRRET strDispName;
SHGetDesktopFolder (&CurrentFolder);
CurrentFolder->BindToObject(pIdl, NULL, IID_IShellFolder, (LPVOID*)&pBrowse);
SHGetPathFromIDList(pIdl, szFolderPath);
pBrowse->GetDisplayNameOf(pNewId, SHGDN_INFOLDER, &strDispName);
PathCombine(szCompletePath, szFolderPath, strDispName.cStr)
MultiByteToWideChar (CP_ACP, 0, szCompletePath, -1, szTemp, sizeof (szTemp) / sizeof (WCHAR));
pBrowse->ParseDisplayName(ghWnd, NULL, szTemp, NULL, &pNewId, NULL);
Thanks all!
|
|
|
|
|
I know many of you probably already have a function that does this, so I'll ask before I do a lot of searching.
I need a simple C function for generating the next prime number given an input number. The prototype for this would be something like:
int GetNextPrime(const int iAfter);
If iAfter is 90, then GetNextPrime would return 101.
I need this to optimize some code I am working on which must initialize the size of an MFC CMap hash table.
|
|
|
|
|
How is this different from lots of class assignment questions posted in the list?
|
|
|
|
|
Hello. I can see how this might be viewed as a class assignment since I know that this type of thing is found in CS courses.
Unfortunantely for me, I am not a student and have never taken any CS courses. I'm sure with some searching on google I can find this kind of thing, but since it is a low priority right now, I thought I would post on CP. It is something I need (eventually) to do with some of my code where I populate CMap objects with varying amounts of data.
Sorry for the confusion.
|
|
|
|
|