Hi, In Internet Explorer, when I click on a link and go back to the previous site I am exactly at the same position of the document where I left. Even the link I clicked is still marked by a thin border. I have an application where I keep track on the history on my own. Now I need exactly the same behaviour. I think i need to save the "state" (scrollposition and "marked" link) in my history array and restore it afterwards when I load the old site again. Does anybody know how to achieve this? If this is hopeless it would also be enough to just save to current (scroll-)position. However, the loaded documents are complex with different divs which have overflow:auto, overflow:hidden etc. So I can't just get_body, query IHTMLTextContainer and afterwards get_scrollTop etc. because those would be the scroll stuff from the document itself... Thank you for any hints! :-)
nobaq
Posts
-
Save/Restore "state" of document in CHtmlView -
List control ignores FindItem?I know what is my error: FindItem and SendMessage(LVM_FINDITEMA) only gives back the index of the found item but the control does not scroll automatically to that position. Is there a way to implement this? I already tried UpdateWindow() and also SetSelectionMark()... Thank you!
-
List control ignores FindItem?Hi and thank you for the help! I tried it with Spy++ and for testing, I typed an 'a'. The message is sent:
<00004> 00070E74 S LVM_FINDITEMA iStart:-1 plvfi:0012E8D8
<00005> 00070E74 R LVM_FINDITEMA iIndex: 86I really don't know why my message handler is not called :-( Niki
-
List control ignores FindItem?Hi, I have an (owner drawn) list control and handle the LVN_ODFINDITEM message. For testing purposes:
void CIndexDlg::OnLvnOdfinditemData(NMHDR *pNMHDR, LRESULT *pResult)
{
LPNMLVFINDITEM pFindInfo = reinterpret_cast(pNMHDR);
*pResult = (rand() % 999) + 1;
}This works good when typing something inside the control. But now I also want to have an external way to find an entry. So I places an edit control in the dialog and want to call FindItem manually:
LVFINDINFO fi;
ZeroMemory(&fi, sizeof(fi));
fi.flags = LVFI_PARTIAL | LVFI_STRING;
fi.psz = m_strWhat;m_ctrlData.FindItem(&fi);
//m_ctrlData.SendMessage(LVM_FINDITEM, -1, (LPARAM)&fi);But in this case, my OnLvnOdfinditemData handler never gets called! I also tried sending manually with SendMessage but it did not work either. What could be the problem?
-
Simple Question: Where to store global object?...or is it better to write a
extern CMyApp theApp;
in every source file needed and use
theApp.GetDabataseManager()
? -
Simple Question: Where to store global object?Ok :-) Is it a good way to store the "DatabaseManager" class as a pointer and do a
new CDatabaseManager(filepath)
inside myCMyApp::InitInstance()
(and an appropriate delete in the destructor)? And then everytime I need it, justdynamic_cast<cmyapp*>(AfxGetApp())->GetMyDatabase()
? Thank you, Niki
-
Simple Question: Where to store global object?Hi, Where to best store a global object in an SDI app? In my case it's a "DatabaseManager" class for accessing an SQLite database. First it was just a member variable of my CDocument but now I need the object in many places in my app. So where to best store it? * Global variable? * Singleton object? * Member variable of CWinApp? * ... One problem: I want to open the database when constructing the object, so the object may throw an "DatabaseException". For this reason a global variable as well as a singleton seem to be suboptimal to me. Niki
-
Concept/example for virtual listHi, thank you for this hint. I've been searching for a while now but I can not find any docs Do you have a reference, docs, howtos for subclassing CListBox in order to implement a virtual listbox? Any anyway, how do I query data from my database when "scrolling" very fast? I think i need to minimze my database queries but on the other hand I need to display something while scrolling... Regards, Niki
-
Concept/example for virtual listI have tried it using caching and virtual list controls. Even if I read only the elements from LVN_ODCACHEHINT and cache them into a map, the list is really, really tooo slow. What could be the solution? I just want to have the same as WinHelp32's keyword (or topic) search. For some reason, this list is very very fast since over 10 years (with slow computers). Regards, Niki
-
Concept/example for virtual listJust look at winhelp32 fulltext- or keyword search. This is exactly what I want to implement. Regards, Niki
-
Concept/example for virtual listHello, I have to correct: The entries are much more than 100000...it's a fulltext recherche of a huge database system. So it's definitifely too large to just read out all entries and cache them. Regards, Niki
-
Concept/example for virtual listHi, I need to display ~ 100000 entries in a windows list which are stored in an SQL database (queried by a SELECT query with a few JOINs). 1st question: In only need to display a simple list. I would really like to use a Listbox Control for the sake of simplicity. Do I really need to choose a (complex) List Control? 2nd question: I tried a virtual list with a simple SQL query:
OnInitDialog()
...
// SELECT COUNT(*) FROM...
m_ctrlWords.SetItemCountEx(count);
....OnLvnGetdispinfoWords(...)
...
sql.Format("SELECT keywordID, keyword FROM keywords ORDER BY keyword LIMIT %d, 1", index);
// query
const char *res = query.getStringField("keyword");
lstrcpy(pItem->pszText, res);but this is really too slow. I think I need OnLvnOdcachehintWords but it's somehow complicated. I could not find any concepts (which data structure to choose??) or examples concerning this :-( The problem is that I have to remove old entried in cache (or my app's memory consumption would explode). Does anyone have implemented such a virtual list (with data in SQL) already? Are there some examples or concepts available? Thank you very much, Niki
-
MFC and dynamic_cast?Thank you very much, I've enabled it now and use dynamic_cast. Yes, I habe VS 2003 .NET. Niki
-
MFC and dynamic_cast?Hello, Is there any reason why dynamic_cast<> is turned off in my MFC projects by default? I always get (in Debug and Release builds).
warning C4541: 'dynamic_cast' für polymorphen Typ 'CWnd' mit /GR- verwendet; unvorhersehbares Verhalten möglich
Is there any reason to not add the /GR switch? Why is this not done by default? The whole C-style casting with objects in the MFC code itself is really bad coding style anyway (C-style casts should not be used any more in C++) Regards, Niki
-
Hiding a viewThank you! This seems to do exactly what I was looking for! Regards, Niki
-
Hiding a viewHello, It sounds crazy but how can I disable and hide my current view in my SDI app (CHtmlView) (and afterwards display it again)? [1] I've tried SetVisible and EnableWindow but it does not work. Background: In a modal dialog I temporarily load a different page for printing. The user should not see that there is another page loading or printing. Regards, Niki [1] With hide/disable I mean e.g. that the current view is just white or even better: just frozen.
-
SDI app: Wait for printerHello and thank you for your answer! I do not want to check if the document has printed successfully but it should just be successfully appended to the queue (before the new document is loaded). I think I managed this (the following code is done in a modal dialog):
// pView is a pointer to my current view (CHtmlView)
// get currently loaded document
CString currentUrl = pView->GetLocationURL();
// load document to be printed
pView->Pall();
// wait until the document has loaded successfully
while(pView->GetReadyState() != READYSTATE_COMPLETE)
{
((CMyApp*)AfxGetApp())->Yeild();
}
// FIXXXME: IS THIS OPERATION REALLY BLOCKING?
pView->OnCmdMsg(ID_FILE_PRINT, 0, 0, 0);
// restore old document
pView->Navigate(currentUrl);
// return to my app
EndDialog(FALSE);The OnCmdMsg(ID_FILE_PRINT) does nothing more than
ExecWB(OLECMDID_PRINT,...)
in the IWebBrowser2. And now my "backup question" is. You said: "Being slightly serious, the OnCmdMsg (ID_FILE_PRINT, 0, 0, 0) shouldn't return until it's finished its bit of the printing process." Are you sure that ExecWB(OLECMDID_PRINT,...) will block until the currently loaded document has been printed so that I can issue the next Navigate(...) call just afterwards? In my tests it works but I am not sure about this. Regards, Niki -
SDI app: Wait for printerI have forgotten a very important issue: The view is a CHtmlView. So my view does not have an own printing mechanism
-
Webbrowser control + ActiveXThe problem was not the browser control itself but my async pluggable protocol! I missed to handle PARSE_SECURE_URL for the secure manager so two different URLs in my protocol were essentially in a different domain. So I got "permission denied"-messages when accessing different frames (cross frame scripting prevention) Regards, Niki
-
SDI app: Wait for printerHello, In my application, I send a print command to my view from a (modal) dialog:
pView->OnCmdMsg(ID_FILE_PRINT, 0, 0, 0);
How can I wait until the printing process has been finished? Background: In my dialog I want to be able to print other data than loaded into the current view. For this purpose, I save the state of the current view, load another document, print it and afterthe document has finished printing I reload the old document again and close the dialog. Thank you and regards, Niki