|
Koma Wang wrote: Why will appear this kind of circumstance?
This makes no sense. Please explain.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
1. i have a SDI window application which open images
2. i have created a search dialog which reads excel as database and loads the datas into the listbox(listview) which resides on the same window.
3. upon user click over the list view content, the image get opened in the SDI window and i need to preserve the search results.
now i able to retrieve the item in the list box (list view) and send it to the Filebrowser() procedure....and opened the file using a global variable..
<br />
<br />
void SearchDlg::OnItemChanged(NMHDR* pNMHDR, LRESULT* pResult)<br />
{<br />
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR; <br />
CString Coll = "";<br />
LV_ITEM itemSelected;<br />
int nSelected = lstCtrl.GetNextItem(-1,LVNI_SELECTED);<br />
<br />
if(nSelected == -1) <br />
{<br />
AfxMessageBox("No more item selected");<br />
}<br />
TCHAR szTeamName[80];<br />
itemSelected.iItem = nSelected;<br />
itemSelected.iSubItem = 9;<br />
itemSelected.mask = LVIF_PARAM | LVIF_TEXT;<br />
itemSelected.pszText = szTeamName;<br />
itemSelected.cchTextMax = 50;<br />
lstCtrl.GetItem(&itemSelected);<br />
<br />
CString* pMessage = (CString*) itemSelected.lParam;<br />
Coll+=szTeamName; <br />
Coll+="\\";<br />
TCHAR temp[2] = "\\";<br />
Coll.TrimRight(temp);<br />
GetsubItems(Coll);<br />
*pResult = 0;<br />
}<br />
<br />
<br />
void SearchDlg::GetsubItems(CString csItem)<br />
{<br />
CString tem_drive = GetDriveName();<br />
CString csFormAbsolutePath = ""; <br />
csFormAbsolutePath = "Files\\" + csItem; <br />
ReturnPathToFileOpen(csFormAbsolutePath);<br />
}<br />
Here i enabled search dialog, according to the search criteria, it lists the results in the listview upon user clicks i need to open the image. here subitem name(usually file name)gives the filename. i want to open the file in the client area.
<br />
CSearchDlg ObjSearch;<br />
ObjSearch.DoModal();<br />
Here the Fileopen was implemented in CImageView.cpp
inside i get the filename with path using global variable, here i couldn't preserve the search results.
i want to know what wrong i did here and how to implement the same.
|
|
|
|
|
lamrinraj wrote: here i couldn't preserve the search results. I'm not sure what you mean by that, but it sounds like you're not saving the search results somewhere that's accessible by the search dialog. Is that what you mean?
|
|
|
|
|
Intially, the search dialog box contains the empty list view. Once click the fetch button it will fetch all the records from the excel file and loads into that list.
Once i close the search dialog manually or by accident,, the next opening time of the dialog the results will not be there. Again i have press the fetch button to get the list. This is because am recreating the search dialog window at each opening.
This is the situation where i have to preserve the previous fetching results on that listview.
I have also tried one method to preserve by calling the API ShowWindow(SW_HIDE) method. But it hides the entire (main) application.
|
|
|
|
|
Do not use DoModal. Hiding modal dialog is not going to help, since main app window is disabled.
Use modeless dialog and toggle visibility as you need.
JohnCz
MS C++ MVP
|
|
|
|
|
Hello,
Which design pattern would you recommend to use, if i want to separeate data from the Business logic in c++ ?
Thanks,
Berlus
|
|
|
|
|
Have a look into MVC architecture[^] to check if this fits your needs.
You talk about Being HUMAN. I have it in my name
AnsHUMAN
|
|
|
|
|
If you are interested in design pattern than go through this link
->[^]
Sometimes I create a COM component for Business logic in C++.
"Every Little Smile can touch Somebody's Heart...
May we find Hundreds of Reasons to Smile Everyday... and
May WE be the Reason for someone else to smile always!" (ICAN)
|
|
|
|
|
Hey guys. I am trying to figure out how i can create totally custom Edit control (something like CEdit, but i do all the painting). Something like this one in Vista's explorer, beautiful semitransparent search entry control. I have started with MFC (myEdit : CEdit) and overriding a different stuff, but the effect is actually miserable. For example it paints in OnChar its ugly white background color and there seems no way to get rid of it. Another question, this blinking cursor which indicates that a control has focus and user can enter some chars into Edit control - how windows paints it? Can you point me to a place where i can find complete information regarding implementation of Edit / Entry controls, or maybe share some knowledge with which window messages should i mess, should i go with MFC or plain Win32 API, etc.
Thanks
011011010110000101100011011010000110100101101110
0110010101110011
|
|
|
|
|
there are a number of completely custom edit controls/text editors here on CP that you could look at. it's a lot of work to write your own editor, but that's the best way to get the exact features you want. CEdit can only do so much...
csrss wrote: this blinking cursor which indicates that a control has focus and user can enter some chars into Edit control
see SetCaretPos.
see this, too[^].
|
|
|
|
|
Thanks very much, this Caret thing info helped a lot
011011010110000101100011011010000110100101101110
0110010101110011
|
|
|
|
|
hi friends i am trying to find the contacts who have a birthday in the next 7 days in my list. i managed get the current time as a string but i am stucked here. i know i must compare only number of the month and day. so use subtraction and if the result is <=7 i will show the contact. but i don't know how to do this. i appreciated if you can help me. and here is the my example code.
#include <stdio.h>
#include <time.h>
#include <string.h>
int main( )
{
char buff[11];
char birth[11]="2011-05-15";
int res;
time_t now = time(NULL);
strftime(buff, 20, "%Y-%m-%d\n", localtime(&now));
res = difftime(mktime(birth), now);
printf("%d", res);
return 0;
}
|
|
|
|
|
quartaela wrote: i know i must compare only number of the month and day.
what if today is the second day of January ?
in any case: Google knows how to do this[^]
|
|
|
|
|
well yes you are right . on the other hand this is C++. i forgot to say that i am working with C.
|
|
|
|
|
the diff between C and C++ will be minimal. basically, get rid of the "std::" scope operators. it's still 2 mktimes and a difftime()/secsPerDay.
|
|
|
|
|
mktime() does not take a string; see here[^] for information on date and time routines. You will need to convert the string to a time_t via the strtod() or similar functions. Note also that your strftime() call has the potential to crash your program since you are telling it that there are 20 elements in buff but you have only reserved 11.
The best things in life are not things.
|
|
|
|
|
but if i give size of 20 to string "buff" how can i manage to make unused fields to 0. and i only read the strings with "YYYY-MM-DD" from a file not including minutes and second etc._?
|
|
|
|
|
strftime() is not any use for what you are trying to do. Go to the link I provided and study the features of the Time & Date routines. You should also spend some time learning the C sizeof operator and how it can help you.
The best things in life are not things.
|
|
|
|
|
well i search all the fields of time.h in the link which you gave me but i can't find any solutions. i guess i will use difftime to compare two dates which are time_t variables. but the problem is i read the birthday string from the file and need to convert this string to time_h variable and then i can compare current time and her/his birthday. i will search another ways.
|
|
|
|
|
quartaela wrote: but the problem is i read the birthday string
As I said before you will need to convert the string to its constituent numbers using strtoi() (sorry not strtod() ) and then use those numbers to populate a tm structure from which you can get the time_t value via mktime() . The documentation for all these functions is available on MSDN starting here[^]. This may all sound long and involved but I'm afraid that is the reality of programming.
The best things in life are not things.
|
|
|
|
|
well i almost near the solution. i use atoi() (i can't use strtoi() cause i guess compiler or O/S doesn't compatible with this function). so this the example code
int main(void) {
char c[11] = "2000/10/15";
printf("the number is %d", atoi(c));
return 0;
}
and the output is 2000. the problem is how can i take other numbers "10" and "15". i guess when i take this numbers i can able to solve the problem.
|
|
|
|
|
You need to split the string into its constituent parts using strtok() .
I would suggest you spend some more time learning some of the more common library functions before going further with your project. Go back to the link[^] I gave you and read through all the alphabetic list so you know (more or less) what functions are available, then you know where to look when you have specific requirements.
The best things in life are not things.
|
|
|
|
|
well finally i managed it . thanks for your help mates .
|
|
|
|
|
What about:
int y, m, d;
sscanf(c, "%d/%d/%d", &y, &m, &d); It's not the best solution, but it does give you something to explore.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
Date/times held in strings are no good for doing calculations, they are only good at interfacing to humans.
Use the time_t type, it basically is the number of seconds since 01-JAN-1970.
Once you have two time_t values, you can simply subtract them and compare to some constant, such as 7*24*60*60.
[ADDED]
POSIX has a nice strptime() function to turn a datetime string into a number; Windows itself hasn't (MFC has, boost has); so your best option may well be:
- use sscanf to turn the string into struct tm; here[^] is an example that should work, provided the month is by number, not by name.
- use mktime to turn that into a time_t
- then either use difftime or simply subtract.
[/ADDED]
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
modified on Tuesday, May 10, 2011 6:27 PM
|
|
|
|