|
Thanks everyone.
The new code works. It use the ostream_iterator and copy() function to output data from the STL deque container to ofstream.
Kuphryn
|
|
|
|
|
So I am almost done my project. Our app is pretty sweet.
So I was checking all the menus to make sure they work properly, and i crashed the app when i tried using the most recently used (mru) list in the File menu.
How do i use this little beast, i only have 4 items at a time showing (set this when i created the app).
I believe if i can get the path from the mru list i can then pass it to my open code (in the same class )
Christian if you are around ? Thank you again for all your help !
Our team actually got an interview with CBC radio (Canadian station) to discuss our app and the technologies used...
Rob Dunsmuir
|
|
|
|
|
|
Thanks Igor,
I have read the documentation in MSDN and online at a few sites.
This is what I have done:
// in my .h
#include <afxadv.h>
CRecentFileList* pMRU;
// in my .cpp
// in my InitInstance()
pMRU=m_pRecentFileList;
// in my OnFileMruFile1()
for(int i = 0; i < pMRU->GetSize(); i++) {
CString strFileName(m_pRecentFileList->m_arrNames[i]);
AfxMessageBox(strFileName);
}
So I can get at all the files in my array (4 of them), but i don't understand how this is connected.
If i click in the mru menu on the first file, when OnFileMruFile1() runs I'd like to find out what was clicked. I was hoping that if i get an index or a string (file path), then I can look it up in the MRU array and pass it to my open file code.
any ideas ?
Thank you.
Rob Dunsmuir
|
|
|
|
|
I'm using the CSystemTray class from http://www.codeproject.com/shell/systemtray.asp , and I can't figure out how to check a menu item from the tray icon's pop-up menu. I can set the default menu item, but I can't set the checked state! Here's the function I use:
[code]
BOOL CSystemTray::CheckMenuItem(UINT uItem, BOOL CheckState, BOOL bByPos)
{
#ifdef _WIN32_WCE
return FALSE;
#else
HMENU hMenu = ::LoadMenu(m_hInstance, MAKEINTRESOURCE(m_tnd.uID));
if (!hMenu)
return FALSE;
HMENU hSubMenu = ::GetSubMenu(hMenu, 0);
if (!hSubMenu)
return FALSE;
::CheckMenuItem(hSubMenu,uItem,MF_UNCHECKED);
return TRUE;
#endif
}
[/code]
The following code works fine:
[code]
BOOL CSystemTray::SetMenuDefaultItem(UINT uItem, BOOL bByPos)
{
#ifdef _WIN32_WCE
return FALSE;
#else
if ((m_DefaultMenuItemID == uItem) && (m_DefaultMenuItemByPos == bByPos))
return TRUE;
m_DefaultMenuItemID = uItem;
m_DefaultMenuItemByPos = bByPos;
HMENU hMenu = ::LoadMenu(m_hInstance, MAKEINTRESOURCE(m_tnd.uID));
if (!hMenu)
return FALSE;
HMENU hSubMenu = ::GetSubMenu(hMenu, 0);
if (!hSubMenu)
return FALSE;
::SetMenuDefaultItem(hSubMenu, m_DefaultMenuItemID, m_DefaultMenuItemByPos);
return TRUE;
#endif
}
[/code]
|
|
|
|
|
Looking at the code, I don't actually see you doing anything with the submenu that you are checking a menu item in.
Usually, you load the menu, check the item, set the default and then use the menu handle in the trackmenupopup call.
When you call LoadMenu, you are creating a copy of the menu from the resources. Thus, if you call LoadMenu twice, you have two instances of the menu. As the code is, you are loading the menu, checking the item and the doing nothing with the menu. Thus you have a resource leak too.
Tim Smith
Descartes Systems Sciences, Inc.
|
|
|
|
|
That's bad .
Thanks for the help!
|
|
|
|
|
Hi !
I'm a beginner.I have a problem.
How to add a function into CView class.Because I want CView support it.
Thanks a lot
|
|
|
|
|
Derive a class from CView, say CView2, and add your functions to CView2
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
Hi,
What is your perference when it comes to STL containers? I know many programmers prefer the vector because it random-access. However, deque container is random-access and could be changed from front, middle and back. I prefer the list, but it is hard for me to access specific data inside the list mainly because of my inexperience with STL. Nonetheless, I prefer list because of the innovative way it manages insert and delete (does not need to move all data).
I am implementing deque a program. The program reads data from a file line by line. The program saves each line of data from the file into a character array. I want to "push" each character array into a deque. At the end, I use the unique function to delete all clones. For example let say I have a file with the following:
-------
123
231
123
321
-------
First, the program reads one line at a time and copy the line into a character array. Then the program copies the entire character array into the STL container. Once the program has reached the end of the file, then it will delete all clones such as "123" from the above example.
How do you push a *character array* into an STL container, specifically a deque?
Thanks,
Kuphryn
|
|
|
|
|
Each container has its place, but I definitely find myself using vector more than anything else. As far as your problem goes, you can use std::string to do what you want, you also might want to consider just using set instead of a deque if you don't care about order (set will automatically remove duplicates).
Chris Hafey
|
|
|
|
|
FYI if you reserve() data in a vector it doesn't have to allocate after each new insert until you exceed it's limit. And at that point it usually allocates 2x it's current data size (1000 -> 2000 -> 4000 etc.)
std::vector<std::string> data(1000);
as for your deque you can use
std::deque<std::string> data;
ifstream infile("filename);
std::string temp;
while (!infile.eof())
{
infile >> temp;
data.push_back(temp);
}
Todd Smith
|
|
|
|
|
Thanks everyone.
I am not familiar with the set container. Can you post a straightforward example of set declaration and insert?
Thanks,
Kuphryn
|
|
|
|
|
Using Visual C++ 6, I need to programmatically, discover what type of keyboard (Serial or PS2) is used on a computer, and what type of mouse (serial or PS2) is used. This needs to be done on Windows 95/98/NT/2000 and XP.
|
|
|
|
|
This registry key might be useful
HKEY_LOCAL_MACHINE\Enum\ACPI
enumerate the subkeys
Nish
p.s. chk for class "Keyboard" and class "Mouse"
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
Hi Nish
I see wrote register address for reply ...
But how can i use of that ?
I must read value of this register key ? with GetKeyValue and ...
My month article: Game programming by DirectX by Lan Mader.
Please visit in: www.geocities.com/hadi_rezaie/index.html
Hadi Rezaie
|
|
|
|
|
Hi
I was home when I posted that reply and I gave you the registry keys for Win 98. Now I find that for Win 2000 the keys are different.
For keyboard :-
Key - HKEY_LOCAL_MACHINE\HARDWARE\DEVICEMAP\KeyboardClass
Query this value - \Device\KeyboardClass0
It will return the registry address to find further info. On my machine I got this - \REGISTRY\MACHINE\SYSTEM\ControlSet001\Services\kbdclass
So I opened that key. By the way replace \REGISTRY\MACHINE\ with HKEY_LOCAL_MACHINE
Open the Enum subkey
Query this value - 0
I got this - ACPI\PNP0303\4&3ec904f&0
So now open this key below :-
HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Enum\ACPI\PNP0303\4&3ec904f&0
Now query this value - DeviceDesc
That will tell you what your keyboard is.
pretty long winded
I didnt chk for mouse. But it should be something similar
Regards
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
Hi All,
How do I get the Friendly Name programmatically of the Name of my current Internet Connection,
currently being used!
eg MyHomeConnectionDun or
TheOfficeLan or
NewDSLConnection ?
Thanks for any and all assistance !
Regardz
Colin J Davies
Sonork ID 100.9197:ColinI live in Bob's HungOut now
Click here for free technical assistance!
|
|
|
|
|
Is there an API to add a header/footer to a PDF?
If so, where can I get it from?
I am not interested in an exe that does this for me.
I'd prefer a library or component that will allow me to programatically stamp all pages of a PDF with a header/footer.
I am prepared to buy a shareware/commercial control.
Regards
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
Have a look at this page : http://www.pdflib.com/
|
|
|
|
|
Thanks Rick.
I am checking it out now
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
If you don't find me on CP, I'll be at Bob's HungOut
|
|
|
|
|
I am trying to get the hang of programming dll's. I succeeded in compiling an example from the MSDN but the problem is i need to import the dll manually (without a .lib file) but it wont work. Here's the code for the DLL:
#include "stdafx.h"
extern "C" VOID assimGL()
{
MessageBox(NULL,"hello world from DLL!","DLL",MB_OK);
}
here's the code for the test app:
#include <stdio.h>
#include "stdafx.h"
typedef VOID (*MYPROC)();
int APIENTRY WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.
//MessageBox(NULL,"hello","hello",MB_OK);
HINSTANCE hinstLib;
MYPROC ProcAdd;
BOOL fFreeResult, fRunTimeLinkSuccess = FALSE;
// Get a handle to the DLL module.
hinstLib = LoadLibrary("assimDLL");
// If the handle is valid, try to get the function address.
if (hinstLib != NULL)
{
ProcAdd = (MYPROC) GetProcAddress(hinstLib, "assimGL");
// If the function address is valid, call the function.
if (fRunTimeLinkSuccess = (ProcAdd != NULL))
(ProcAdd) ();
// Free the DLL module.
fFreeResult = FreeLibrary(hinstLib);
}
if(!fRunTimeLinkSuccess)
{
MessageBox(NULL,"Link failed!","Failure",MB_OK);
}
return 0;
}
Can anyone please tell me whats wrong with it and how it WILL work for sure?
Thanks in advance
Kuniva
|
|
|
|
|
It appears that assimGL is not exported. It needs to have a __declspec(dllexport) statement in front of it.
Have a look at the DLLHUSK sample in MSDN. It illustrates this fairly well.
|
|
|
|
|
Also take note of the calling convention of the exported DLL function (i.e. __stdcall or __cdecl).
This will affect how the function name will appear in the export table of the DLL which will in turn determine whether function GetProcAddress() succeeds.
To keep things simple, always add a .DEF file to your DLL project and add a EXPORTS section to it. Then make sure that the function name "assimGL" is listed in this section. For example :
LIBRARY assimDLL
EXPORTS
assimGL
|
|
|
|
|
I am in need to place a hyperlink on a dialog. In want the user's browser to come up, when the link is clicked (just like a standard hyperlink to a HTM resource).
Is there an easy way to do this, or do I have to detect the mouse click, search for the default browser and spawn an instance of it?
Thank You
LP
|
|
|
|