|
shouvik.d wrote: query="Select * from Book where Name like '%"+name.Left(5)+"%' AND Author LIKE '%"+auth.Left(5)+"%' Order By Ac_No" ; m_pSet->Open(CRecordset::dynaset, (LPCTSTR)query,CRecordset::none);
I hope this gives you expected no. of records.
Use CRecordset::m_strSort to sort the records.
|
|
|
|
|
I tried but funniest part is its adding the records instead of sorting them so i used a query instead.
Shouvik
|
|
|
|
|
shouvik.d wrote: I tried but funniest part is its adding the records instead of sorting them
Can you show code ? what you have tried ?
It can be,
m_pSet->Open();
m_pSet->m_strSort = "par, par1";
m_pSet->Requery();
|
|
|
|
|
But the records are already sorted.
Shouvik
|
|
|
|
|
shouvik.d wrote: But the records are already sorted
By what ? If it is sorted by Ac_No , MoveFirst() should point to correct record in order.
|
|
|
|
|
I said its all entered in Ascending order.
So the retrievel is sorted irrespective of anything.
Still the pointer remains stuck at 1118. i'm g:(ing nuts
Shouvik
|
|
|
|
|
Try this instead:
m_pSet->Close();
query = "Select * from Book where Name like '%" + name.Left(5) + "%' AND Author LIKE '%" + auth.Left(5) + "%' Order By Ac_No";
m_pSet->Open(CRecordset::dynaset, query, CRecordset::none);
while(! m_pSet->IsEOF())
{
name = m_pSet->m_Name;
auth = m_pSet->m_Author;
Item = m_pSet->m_Ac_No + "\t" + name + "\t" + auth + "\t" + CLibManView::GetStatus(m_pSet->m_Stat);
lb->AddString(Item);
m_pSet->MoveNext();
}
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Sorry David
Still stuck at 1118. cant trace out the prob at all. I think the internal pattern of storage is so that 1118 is the first record.
Success makes life easier. It doesn't make living easier.
SHOUVIK
|
|
|
|
|
Since nothing worked out i changed the whole structure
its like this
void CLibManView::OnDblclkBooks()
{
CString str;
lb->GetText(lb->GetCurSel(),str);
m_pSet->Close();
query = "Select * from Book where Ac_No='"+str.Left(4)+"'";
m_pSet->Open(CRecordset::dynaset, (LPCTSTR)query,CRecordset::none);
if(m_pSet->IsBOF() && m_pSet->IsEOF())
MessageBox("No records available in the database");
else
{
MessageBox(m_pSet->m_Ac_No+" "+GetStatus(m_pSet->m_Stat));
}
}
this works with precision
Success makes life easier. It doesn't make living easier.
SH UVIK
|
|
|
|
|
hi,
when creating a MDi how do i change the name of the pop up window. it comes with "new". how do i change it?
|
|
|
|
|
wrote: when creating a MDi how do i change the name of the pop up window. it comes with "new". how do i change it?
Which pop up window ? Can you reword this for clear understanding ?
wrote: Sender:
Date:6:01 29 Dec '06
Nice nic name
|
|
|
|
|
wrote: ...the pop up window.
Which one?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Hi All,
My program is fine when working with Debug mode. But When it is with Release mode it is giving run time error..
What it is ?
Really what is happening behind this ?
Kindly Help me...
Thanks.
|
|
|
|
|
Hi,
hm ... check if all pointers are initialized
-----------
Mila
|
|
|
|
|
Require neat code review .
Refer this[^] article for better understanding.
|
|
|
|
|
As stated by Mila025 maybe an initialization problem. uninitialized vars gets zeroes in debug mode, but gets garbage in release one. For instance if you pass a struct to a Windows API, and you not initialize it, then maybe zeroes will be harmless, while garbage will make your program crash.
hope that helps
-- modified at 6:11 Friday 29th December, 2006
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Which is the error you getting ?
If u can Dream... U can do it
|
|
|
|
|
This is something very common,
You should look:
- If your pointers are correctly initialized.
- If you are using some dll's or specific external files or programs, you should take a look if they are placed in the debug and in the release folders. (think that if somewhere of the app you are using something like GetAppPath() then you can have some problems related to files that could be in the debug folder but not in teh release one.
- Look in the project options that you have the same configuration in the DEBUG than in the RELEASE.
- There can be several other things, this can be hard to find out what is happening, but if you cannot find the problem you can always try to use MessageBoxes spreaded from the beggining to the end in order to be able to give us more information on what's happening, where and when.
Hope this helps even if it is not a very good answer.
|
|
|
|
|
Hi,
i load bitmap data by using fopen/fread standard c functions. after reading the whole image in a buffer i calculate bitmapfileheader and bitmapinfoheader from that buffer that is ok without any problem. now i want to draw this image but i am unable to draw it. i use CBitmap CreateBitmap function to create image from this data but when i draw the image it is in black color. here is code how i try to do it.
file = fopen("test.bmp", "rb");
fseek(file, SEEK_END, SEEK_END);
nSize = ftell(file);
byBmp = new BYTE[nSize];
fseek(file, SEEK_SET, SEEK_SET);
memset(byBmp, 0, nSize);
fread(byBmp,nSize, 1, file);
BITMAPFILEHEADER bmfh;
memcpy(&bmfh, byBmp, sizeof(bmfh));
BITMAPINFOHEADER bmih;
memcpy(&bmih, byBmp + sizeof(bmfh), sizeof(bmih));
BOOL b = m_bmpBackImage.CreateBitmap(bmih.biWidth, bmih.biHeight, bmih.biPlanes, bmih.biBitCount, NULL);
m_bmpBackImage.SetBitmapBits(bmih.biWidth*bmih.biHeight, byBmp + bmfh.bfOffBits);
somewhere onpaint event i try to draw this bitmap but end result is black image.
please help how can i create image from a buffer data. is there any thing that i am missing.
thanks in advance.
Omar Lodhi
|
|
|
|
|
There is a MSDN sample demonstrating the usage of bitmaps from files.
I forgot the sample name, but I am pretty sure you can search for "SaveBmp".
Anyway, I think you are doing something wrong not at bitmap loading, but bitmap drawing.
Try to use the standard steps:
CreateCompatibleDC (--> memory DC)
CreateCompatibleBitmap (--> memory bitmap)
select memory bitmap in memory DC
draw in memory bitmap
BitBlt from memory DC into window DC
destroy/release all (HBITMAP, HDC etc)
|
|
|
|
|
Hi,
thanks for your help, i have tried to search from msdn but no result i will try it again. here is the code i try to draw bitmap.
dcMemBkImage.CreateCompatibleDC(pDC);
//this image was previously created
dcMemBkImage.SelectObject(&m_bmpBackImage);
GetObject(m_bmpBackImage,sizeof(bitmap),&bitmap);
pDC->BitBlt(m_nLeft, m_nTop, bitmap.bmWidth, bitmap.bmHeight, &dcMemBkImage, 0, 0, SRCCOPY);
dcMemBkImage.DeleteDC();
please guide me if there is some error in this code.
thanks,
omar lodhi
|
|
|
|
|
m_bmpBackImage should be a result of CreateCompatibleBitmap.
(I don't know if works with a cached CBitmap variable).
After this, try to use SetBitmapDimension to set the bitmap size, load data from bitmap file, and call SetDIBits to set bitmap data. Now you should have the memory bitmap completed.
(I suppose this is what GetObject does?)
Finally, call BitBlt to transfer the bitmap from memory into DC.
|
|
|
|
|
Hi,
i have little bit confusion like u said to create using CreateCompatibleBitmap.
Is it necessary to create the bitmap this way?
I am creating the bitmap as i mentioned in the first post like this
nWidth = bmih.biWidth*3;
if(bmih.biWidth*3%4 != 0)
{
nWidth = bmih.biWidth*3 + 4-(bmih.biWidth*3%4);
}
BOOL b = m_bmpBackImage.CreateBitmap(bmih.biWidth, bmih.biHeight, bmih.biPlanes, bmih.biBitCount, NULL);
m_bmpBackImage.SetBitmapBits(nWidth*bmih.biHeight, byBmp + bmfh.bfOffBits);
will it not work if the image is created in this way.
thanks for your help.
omar lodhi
|
|
|
|
|
If you just need to load and draw a bitmap from a file, use LoadImage[^] to load the bitmap, and then normal drawing techniques.
Software Zen: delete this;
|
|
|
|
|
Can you use of CImage class?
|
|
|
|