DockPanel Suite add the docking functionlity to C# application. The effect is similiar to the
docking effect in Visual Studio 2008.
Installation steps:
1. Download the dll at SourceForge.
2. Open Visual Studio, add reference to the dll
Step1
Step2
3. Add DockPanel to ToolBox
Step1
Step2
Step3
Step4
4. Drag DockPanel to Form 1
Step1
5. Change IsMdiContainer to true. Beware!!! This is crucial step, or your program will crash!!!
Step1
6. Add an new form (Form2)
Step1
May 9, 2009
DockPanel Suite Installation Tutorial
Posted by Lono at 19:51 1 comments
Labels: Programming
Mar 27, 2009
boost asio for windows pipe bug -- ERROR_MORE_DATA
I encountered another asio bug today.
I created a pipe server and used a pipe client to send data to the server.
The server read 128 bytes for each read, but the client sends 65536 bytes for each write. When the server read the data, ::ReadFile returns ERROR_MORE_DATA.
Then it just crashed.
The root cause is at function "async_read_some_at" in the file "win_iocp_handle_service.hpp".
DWORD bytes_transferred = 0;
ptr.get()->Offset = offset & 0xFFFFFFFF;
ptr.get()->OffsetHigh = (offset >> 32) & 0xFFFFFFFF;
BOOL ok = ::ReadFile(impl.handle_,
boost::asio::buffer_cast(buffer),
static_cast(boost::asio::buffer_size(buffer)),
&bytes_transferred, ptr.get());
DWORD last_error = ::GetLastError();
if (!ok && last_error != ERROR_IO_PENDING)
{
boost::asio::io_service::work work(this->get_io_service());
ptr.reset();
boost::system::error_code ec(last_error,
boost::asio::error::get_system_category());
iocp_service_.post(bind_handler(handler, ec, bytes_transferred));
}
else
{
ptr.release();
}
}
In the above code,
if (!ok && last_error != ERROR_IO_PENDING)
{
boost::asio::io_service::work work(this->get_io_service());
ptr.reset();
boost::system::error_code ec(last_error,
boost::asio::error::get_system_category());
iocp_service_.post(bind_handler(handler, ec, bytes_transferred));
}
Checks for any error. When last_error != ERROR_IO_PENDING, the function assumes that the call to ::ReadFile is failed, so it release ptr immediately. But when last_error is ERROR_MORE_DATA, the call is successful and the ReadComplete event will still be put in the complete queue. Since the ptr has been released, the LPOVERLAPPED returned by ::GetQueuedCompletionStatus points to invalid location and is causes crash.
The fix is simple, just change the code to
if (!ok && (last_error != ERROR_IO_PENDING && last_error != ERROR_MORE_DATA) )
{
boost::asio::io_service::work work(this->get_io_service());
ptr.reset();
boost::system::error_code ec(last_error,
boost::asio::error::get_system_category());
iocp_service_.post(bind_handler(handler, ec, bytes_transferred));
}
Posted by Lono at 00:21 1 comments
Labels: Programming
Jul 7, 2008
Great website
>http://www.gorillatraining.com
contains a lot of information about Windows programming reference
>http://thesource.ofallevil.com
contains a lot of information about Microsoft Corporation info
Posted by Lono at 07:18 0 comments
Labels: Programming
May 15, 2008
ruby-serial port on windows
mark this
#require "../serialport.so"
add this
Kernel::require "serialport"
Posted by Lono at 01:17 0 comments
Labels: Programming
Mar 26, 2008
swig & opencv & ruby
1.swig commands to link ruby & c++
swig -c++ -ruby Wrapper.i
ruby mkmf.rb Wrapper
make
ruby hello.rb
2.modify the makefile
2.1add the following lines below definition of CFLAGS & DLDFLAGS
CFLAGS += `pkg-config opencv --cflags`
DLDFLAGS += `pkg-config opencv --libs`
2.2 remove -arch ppc at following lines
DLDFLAGS = -L. -arch ppc -arch i386
LDSHARED = cc -arch ppc -arch i386 -pipe -bundle
3.If you don't want to mess your makefile
require 'mkmf'
$libs = append_library($libs, "stdc++")
$CFLAGS << " `pkg-config opencv --cflags`"
$LDFLAGS << " `pkg-config opencv --libs`"
create_makefile(ARGV[0])
from
http://developer.apple.com/releasenotes/OpenSource/PerlExtensionsRelNotes/index.html
% env ARCHFLAGS='-arch ppc' ruby extconf.rb
% make
% make install
Posted by Lono at 09:17 0 comments
Labels: Programming
Mar 25, 2008
OpenCV on Mac
New Setting:
1.
PKG_CONFIG_PATH=/opt/local/var/macports/software/opencv/1.0.0_0/opt/local/lib/pkgconfig: ${PKG_CONFIG_PATH}
2.
export PKG_CONFIG_PATH
3.
g++ `pkg-config --cflags opencv` `pkg-config --libs opencv` -o water watershed.cpp
g++ -c Wrapper.cxx `pkg-config opencv --cflags`
g++ -o hello Wrapper.o `pkg-config opencv --libs`
./hello
export PKG_CONFIG_PATH=/opt/local/lib/pkgconfig
Makefile:
#by lono kao, 970325
CXX = g++
CFLAGS += `pkg-config opencv --cflags`
LDFLAGS += `pkg-config opencv --libs`
#LTool/LImage
TARGET = deleteme
SRC = LTool/LImage.cpp deleteme.cpp
#SRC = a.c b.c
#OBJ = $(SRC:.c=.o)
all : $(TARGET)
$(TARGET) : $(TARGET).cpp
$(CXX) $(SRC) $(CFLAGS) $(LDFLAGS) -o $(TARGET)
.cpp.o : $*.cpp
$(CXX) $*.cpp $(CFLAGS) $(LDFLAGS) -o $*
clean :
rm -f $(OBJS) $(TARGET)
Posted by Lono at 09:13 0 comments
Labels: Programming